LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need to run scripts after booting and before shutting in runlevel 5 (https://www.linuxquestions.org/questions/linux-newbie-8/need-to-run-scripts-after-booting-and-before-shutting-in-runlevel-5-a-4175554333/)

#linux 09-23-2015 04:04 PM

Need to run scripts after booting and before shutting in runlevel 5
 
hello,

I have some commands in .bash_login and .bash_logout and it works in runlevel 3 i.e console mode.

In runlevel 5 which is the GUI mode, .bash_login and .bash_logout is ignored. What equivalent files do I need to edit or create to do things after booting up and before shutting down in runlevel 5?

=-o

John VV 09-23-2015 07:31 PM

what old operating system are you using ?
most current OS's use systemD and do not use "runlevel" anymore

they use "*.target "

#linux 09-23-2015 07:39 PM

I'm using pclinuxos 64bit. It still uses init

I know how to run scripts at boot up now, but I'm not sure what files I need to edit or create to run when shutting down.

=-o

jpollard 09-23-2015 07:47 PM

It depends on what the scripts actually do.

It is possible that it isn't boot/shutdown you need, but GUI login/logout, in which case it goes somewhere else - such as /etc/X11/xinit/Xsession

It can also depend on what GUI display manager you are using, as those put login/logout in different places, and may not use the Xsession file at all.

#linux 09-23-2015 08:08 PM

I appreciate the hints of where to start, if that doesn't work, then I'll try the pclinuxos forum. Maybe they can tell me which files to edit or create to run scripts before shutting down the system.

=-o

doni 09-24-2015 08:18 AM

Not sure what is your system architectire but if you are running SYSTEM V try putting the script in:
/etc/init.d/
Grant it executable permissions:
chmod 755 script.sh

and if you want to have it on runlevel 5:

chkconfig 5 90 10

First number is the runlevel, second is when it will start withiin runlevel 5 and last number is when it will stop


All times are GMT -5. The time now is 04:33 PM.