Results 1 to 5 of 5
I want to run a bash script when my pc shut down.
Suppose the script is myscript.sh
How can I do this ?...
- 06-10-2009 #1Just Joined!
- Join Date
- Dec 2008
- Posts
- 18
Running a script when the pc shut down
I want to run a bash script when my pc shut down.
Suppose the script is myscript.sh
How can I do this ?
- 06-11-2009 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
I don't know what the best solution is, but the script /etc/rc.d/init.d/halt is executed when the system is shut down or rebooted. You could put a call to your script there. Test if it exists, and if so, then execute the script. This would occur before the system terminates and then kills running processes.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 06-11-2009 #3Just Joined!
- Join Date
- Jun 2009
- Posts
- 3
#Perhaps you have to edit your crontab.
#Use the command
crontab -e
- 06-11-2009 #4
- 06-12-2009 #5Just Joined!
- Join Date
- Jul 2008
- Location
- Kenya
- Posts
- 26
This has nothing to do with cron. Cron schedules jobs at specified time.
if you need to run the script everytime you shutdown, then include a call to your script in /etc/rc.d/init.d/halt
or
including shutdown command inside the myscript.sh so that when you run your script it will shutdown the machine after execution.


Reply With Quote
