1836694 Members
2455 Online
110108 Solutions
New Discussion

run script when shutdown

 
O'lnes
Regular Advisor

run script when shutdown

How can the system automatically run the scripts such as shutdown db , logout users when the system is shutdown?
Thx.

Andy
3 REPLIES 3
Khalid A. Al-Tayaran
Valued Contributor

Re: run script when shutdown


Hi,
Here's a partial answer:
1- write your script in a case segment including start, stop, start commands

2- save the script in /sbin/rc.init.d/your_script

3- create a symbolic link to this file in /sbin/rcR.d/ where R is the appropriate run level during STARTUP. Name the link sarting with an S (start) like (S540) the numbers here are for the order execution during startup.

4- create another symbolic link for the file in /sbin/rcR.d/ where R is the appropriate run level during SHUTDOWN.
Name the link sarting with an K (Kill) like (K540) the numbers here are for the order execution during shutdown.

4- Create additional configuration parmeters if any in /sbin/rc.config.d/ with the same name in /sbin/init.d/

Hope this works,,,,

Good Luck.
Darrell Allen
Honored Contributor

Re: run script when shutdown

Hi,

As a general rule, you create the symbolic link for the stop case of your script one run level less than where you start it. In other words, if you start a process at run level 3, you generally want to stop it at run level 2.

For example:
create /sbin/init.d/myscript
ln -s /sbin/init.d/myscript /sbin/rc3.d/S100myscript
ln -s /sbin/init.d/myscript /sbin/rc2.d/K900myscript

Darrell

"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
harry d brown jr
Honored Contributor

Re: run script when shutdown


How about spending some time fixing this? it's just plain laziness and lack of RESPECT for your fellow system admins that irks me to no end!


This member has assigned points to 158 of 347 responses to his/her questions.


You can find ALL of your previous posts here:

http://forums.itrc.hp.com/cm/TopSolutions/1,,CA759973!1!questions,00.html


live free or die
harry
Live Free or Die