1837170 Members
2585 Online
110113 Solutions
New Discussion

Shutdown from UPS

 
SOLVED
Go to solution
Kevin Daines
Advisor

Shutdown from UPS

Does anyone know of a way to run a script when HPUX shuts down after a power failure, i.e. when power fails and the ups-conf kicks in, can i tell it to run a script to shutdown my databases cleanly!
11 REPLIES 11
Steven E. Protter
Exalted Contributor

Re: Shutdown from UPS

This is simply a matter of correct rc configuration.

Database start/stop script is in /sbin/init.d/

directory, I'm attching my oracle script as a template

then a soft link in /sbin/rc3.d K200oracle that points to the /sbin/init.d/oracle script

When ups_mond shuts down the machine, the database will come down normally.

If its oracle, make sure you use shutdown immediate.

LEt me know if you need more details

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Pete Randall
Outstanding Contributor

Re: Shutdown from UPS

Kevin,

The database should be handled by the normal shutdown processes (i.e. /sbin/init.d/database and the /sbin/rc(runlevel).d links).


Pete

Pete
Tim Sanko
Trusted Contributor

Re: Shutdown from UPS

I have made it a practical exercize to modify /etc/shutdown.

I added "su - oracle -c $ORACLE_HOME/bin/dbshut"

Steven E. Protter
Exalted Contributor

Re: Shutdown from UPS

I'd recommend against using dbshut.

It hangs.

I've written a better one.

Attaching

as tar file
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Kevin Daines
Advisor

Re: Shutdown from UPS

Steve,

Would i get away with a link in rc3.d, that links to a file in init.d called dbasestart:

case "$1" in

start)
/qad/scripts/start.All
;;

stop)
/qad/scripts/stop.All
;;

esac

Would this use the start script on entering run level 3 and the stop script on exiting run level 3?
Pete Randall
Outstanding Contributor

Re: Shutdown from UPS

Kevin,

The start script would be invoked when entering run level 3, but the stop script should be the first thing done when entering run level 2, like this:

ll /sbin/rc?.d/*informix
lrwxrwxrwx 1 root sys 21 Jun 2 2000 /sbin/rc2.d/K100inform
ix -> /sbin/init.d/informix
lrwxrwxrwx 1 root sys 21 Jun 2 2000 /sbin/rc3.d/S998inform
ix -> /sbin/init.d/informix

Obviously you would not be using informix!!


Pete

Pete
Kevin Daines
Advisor

Re: Shutdown from UPS

Pete,

Just to confirm, the 'S???' and the 'K???' at the beginning of the link in the relevent rc?.d directory is the method by which the run level being invoked 'knows' to run the Start(S???) or Stop(K???) part of the script in init.d

I hope that makes sense!
Pete Randall
Outstanding Contributor

Re: Shutdown from UPS

Kevin,

Exactly. I should have mentioned it.


Pete

Pete
Kevin Daines
Advisor

Re: Shutdown from UPS

And the number which follows the S and K need to be unique? As in I assign a unique number to each in the range 1 to 999?
Pete Randall
Outstanding Contributor
Solution

Re: Shutdown from UPS

Kevin,

The number determines the order with the Start or Kill scripts. I like to do the database last so I use the S998 and the K100, so that it's started late on entering run-level 3 and early on entering run-level2. They actually don't have to be unique but if they're not, it's a crap shoot what order the non-unique scripts get executed.


Pete

Pete
A. Clay Stephenson
Acclaimed Contributor

Re: Shutdown from UPS

It's not really a crapshoot as to which scripts get run even if you have duplicate K100xxx scripts. The scripts are evaluated in lexical order so that K100aaa will run before K100aab. Having said that why make it hard on yourself.

A good convention (and it is nothing more than that) is to have your Snnn and KNNN values sum to 1000. For example if you have an S900 startup script, you should have a K100 kill script. The other convention is that if a process/service is started at run level N, it should be killed at run level N-1 and both of these should be a softlink to the "real" script in init.d.
If it ain't broke, I can fix that.