Run a script on Startup / Shutdown in Linux
Hi all, Been a long time! I’ll try to be more regular from now on. Here’s a simple post on how to add a script to your system startup or shutdown
Write a script. Lets call it foo.sh
Now, to start the script on startup -
update-rc.d -f foo.sh start 99 2 3 4 5 .
where
- start is the argument given to the script (start, stop).
- 99 is the start order of the script (1 = first one, 99= last one)
- 2 3 4 5 are the runlevels to start
Dont forget the dot at the end
Start my_script on shutdown and reboot :
# update-rc.d -f foo.sh start 90 0 6 .
Stop my_script on halt and reboot :
# update-rc.d -f foo.sh reboot 90 0 6 .
That’s all. Have fun!


















“Write a script. Lets call it foo.sh”
bit more in how to write,may be useful for new commers,like me.
Thanks
Also I think you should explain that this script must be in /etc/init.d for the commands to work, I think. And you have to execute the commands and the placing of the file on /etc/init.d as root.
command not found in RHEL 5.3