1832296 Members
1903 Online
110041 Solutions
New Discussion

Shutdown script

 
SOLVED
Go to solution
Thayanidhi
Honored Contributor

Shutdown script

Hi,
I would like to know whether any place/script used when the system being shutdown gracefully.
E.g. I want add some additional commands in shutdown script. If I am correct in hp-ux 9.x /etc/shutdown was the place you put any script will executed when system being shutdown. in 11.x how to do the same thing. it may be possible by adding the lines to any of the K??? scripts in /sbin/rc0.d
Or may be I need to edit /sbin/rc
Is there any other easy way?

Thanks in advance

TT
Attitude (not aptitude) determines altitude.
8 REPLIES 8
Tom Geudens
Honored Contributor

Re: Shutdown script

Hi,
It may be that I misunderstand your question, but the best way is to "balance" your stop/start scripts.
Example : Let's say you start Oracle somewhere at the beginning of runlevel 3 :
wroot/sv00239#ll /sbin/rc3.d
total 0
lrwxr-xr-x 1 root sys 19 Sep 26 2001 S009oracle -> /sbin/init.d/oracle

Then logic would dictate you stop Oracle at the end of runlevel 2 :
wroot/sv00239#ll /sbin/rc2.d
total 0
lrwxr-xr-x 1 root sys 19 Sep 26 2001 K991oracle -> /sbin/init.d/oracle

I try to "complement" the links (S009 versus K991). This avoids confusion ...

Was this what you are looking for ?
Regards,
Tom
A life ? Cool ! Where can I download one of those from ?
Thayanidhi
Honored Contributor

Re: Shutdown script

Not exactly,

The system is triggering a shutdown due to shutdown command executed, or hardware failure such as over temp/chasis fan ..etc.
It is as simple as that, when system being shutdown, the system should send a e-mail.
I think in /etc/rc0.d editing any K??? script will do, but is there any other place?

TT
Attitude (not aptitude) determines altitude.
Thayanidhi
Honored Contributor

Re: Shutdown script

There was a typo. It is "/sbin/rc0.d" not /etc/rc0.d
Attitude (not aptitude) determines altitude.
Tom Geudens
Honored Contributor

Re: Shutdown script

Hi,
Sorry for not understanding the question in the first place. I'm afraid there is no easy way. You might be able to "catch" some cases with the envd-daemon (check "man envd" for more information). Using EMS will give you an indication of why the system went down.

Note that the mailservices are probably no longer running when you get to /sbin/rc0.d in an ordinary shutdown !

Regards,
Tom
A life ? Cool ! Where can I download one of those from ?
Thayanidhi
Honored Contributor

Re: Shutdown script

Hi,

I think you are correct!
I could edit /etc/envd.conf to send mails in case of over temp or fan failure. But when some one gracefully shutting down the system, how to generate mail? Should I do it in run level 3 to 2 transition(/sbin/rc2.d/K???), because runlevel 1 will not be running networking/sendmail deamons. Correct me If I am wrong.

TT
Attitude (not aptitude) determines altitude.
Tom Geudens
Honored Contributor

Re: Shutdown script

Hi,
No correction needed, if you want the mail, do it before the daemons (not to mention the network) are down.
An alternative might be to have your systems monitored (by HP Openview as an - very expensive - example).

Regards,
Tom
A life ? Cool ! Where can I download one of those from ?
James R. Ferguson
Acclaimed Contributor

Re: Shutdown script

Hi:

Starting with 10.0 the startup/shutdown paradigm changed. The document link below offers a pdf file which applies to HP-UX starting with 10.0 and continuing through current 11i releases. It should easily answer all your questions.

http://docs.hp.com/hpux/onlinedocs/os/startup.pdf

Regards!

...JRF...
Bill Hassell
Honored Contributor
Solution

Re: Shutdown script

The easiest way is to simply create a start/stop script in /sbin/init.d and call it startstopnotify. It would look at two variables, something like NOTIFYSTOP and NOTIFYSTART. Set these two variables in /etc/rc.config.d/startstopnotify (zero = no message, non-zero = do whatever you need as a notification).

Now create 2 symlinks to /sbin/init.d script in /etc/rc2.d and call it K090startstopnotify and S992startstopnotify as an example. The script might just use mailx to send a mail or pager message.

The concept behind the start/stop scripts is to break up independent features so they can be selectively enabled at bootup (and shutdown in a formal manner). The S992 link name ensures that the startstopnotify script is one of the last scripts run at startup. This is because you'll likely need networking and sendmail functional before you send the notification. Conversely, K099 means that the notification will go out before sendmail and networking are terminated. By keeping all the notification functions in this script, you won't have to worry about HP-UX standard scripts getting patched and losing custom code.

See attached example.


Bill Hassell, sysadmin