Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How could a script be started at at shutdown?

Status
Not open for further replies.

firelex

Programmer
Jan 10, 2002
118
DE
Hi, all!
My problem is : I want a shell script be started every time when the system is going to shut down. Has anybody any ideas?
Thanks

 
Include the shutdown command at the end of the script.

ChrisP If someone resolves an issue for you, or was helpful, please click the link on the bottom left hand corner of their post to give them a "star" letting them know they helped you.
 
It´s a good idea. I´ve already done something like that, but what I was looking for is e.g. a file that is read after the shutdown is called, so that an entry in that file could call my script.
 
look in /etc/rc6 and rc0 and you'll see shutdown scripts. 0 is poweroff and 6 is reboot.
if you're not sure how this works then ls -l all the rc directories and you'll see how it's done.
 
MrTom's suggestion will also work. The /etc/rc.d/rc6.d directory is full of scripts that are run when rebooting, and the /etc/rc.d/rc0.d directory is for shutting down. Either copy your script in one (or both) of those directories or create a symbolic link.

ChrisP If someone resolves an issue for you, or was helpful, please click the link on the bottom left hand corner of their post to give them a "star" letting them know they helped you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top