Run a script on Startup / Shutdown in Linux
March 24, 2007 20 Comments
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 😦
This isn’t for Red Hat like systems. It’s Debian/Ubuntu only. Red Hat/CentOS use chkconfig
Pingback: ter Smitten's » Using init (bootup & shutdown) scripts in Debian/Ubuntu
I was wondering if the last command was incorrect.
# update-rc.d -f foo.sh reboot 90 0 6 .
Does the “reboot” argument exist in this context?
Shouldn’t the command be like
# update-rc.d -f foo.sh stop 90 0 6 .
@ivalo The article was written a long time ago. You’re probably right thanks for pointing it out
Pingback: Power off USB mass storage at computer shut down??
Many thanks for an explanation, now I will know.
By the way, what do you think about this icons site?
You’re welcome!
Awesome post.
Thank you
Whether you have had the privilege of seeing some of the world’s most majestic animals up close or simply have appreciated them from afar through books, movies or on television, giant stuffed toys can give you that warm and fuzzy feeling we all hope to find. Make your children more happy by giving quadrilla try me set precio and quadrilla basic set. So, if you are planning to surprise your kid on his or her birthday, do buy some best toys for them online from one of best toys companies like the Fisher Price, Play Tool, Hot Wheels and many more as they sell genuine toys with long lasting effect.
When I initially commented I clicked the “Notify me when new comments are added” checkbox and now
each time a comment is added I get four e-mails with the same comment.
Is there any way you can remove people from that service?
Thank you!
I blog quite often and I seriously thank you for
your content. The article has truly peaked my interest.
I’m going to take a note of your blog and keep checking for new details about once per week.
I subscribed to your RSS feed too.
If some one needs expert view about blogging and site-building afterward i recommend him/her to pay a
visit this web site, Keep up the fastidious work.
There is definately a lot to know about this subject.
I like all of the points you have made.
Mahjong can be a online game connected with China community
that is enjoyed, Mahjong some avid gamers, along with items known as tiles.
Mahjong Merging practices
半袖T-ブランド tシャツ コピーの通販.弊社プロの誠実、品質が保証しております、ではブランド 服 スーパーコピー通販 、 ブランド 偽物服 通販取扱い店です. シュプリーム コピー Tシャツ_SUPREME スーパーコピー ブランド スリッパサンダルコピー メンズと レディースのブランド 服 スーパーコピー .
シュプリーム ボックス ロゴ パーカー コピー http://www.amecioc.com/
Pingback: Attaching some code to session start and end in Linux