Operating System - HP-UX
1847000 Members
3579 Online
110257 Solutions
New Discussion

run script during server shutdown?

 
SOLVED
Go to solution
Peter A. Berger Jr.
Regular Advisor

run script during server shutdown?

I would like to confirm with experienced System and Oracle admins out there that my thinking would work?

I want the "shutdown -ry now" command to run an Oracle shutdown script automatically before continuing to shutdown the rest of the HP-UX Operating system.

If I were to create an "/sbin/rc3.d/K001oracle" file and have it symbolically linked to "/usr/local/bin/stop_oracle.sh" script, would this work to shutdown Oracle properly and then continue to shutdown the HP-UX OS and reboot the server?

PS: My Oracle DBA wrote the "/usr/local/bin/stop_oracle.sh" script and we know this works fine by itself.

Likewise, if I put in an "/sbin/rc4.d/S001oracle" script linked to "/usr/local/bin/start_oracle", would this start Oracle when the server boots up?

Any information, tips, etc. would be great to this newbie UX Admin. thanks...
9 REPLIES 9
James R. Ferguson
Acclaimed Contributor
Solution

Re: run script during server shutdown?

Hi:

The manpages for 'rc(1M)' or the original 10x document below offer everything you should know:

http://docs.hp.com/en/B2355-60127/rc.1M.html

http://docs.hp.com/en/934/startup.pdf

Regards!

...JRF...
Pete Randall
Outstanding Contributor

Re: run script during server shutdown?

You're on the right track. Generally, the same script handles both startup and shutdown. The startup version should probably be one of the last things you want to do, so I would suggest /sbin/rc4.d/S999oracle, as they are parsed in order. On the shutdown side, K001oracle is fine, as they are parsed in reverse order. The documents JRF pointed you to explain all the details.


Pete

Pete
DCE
Honored Contributor

Re: run script during server shutdown?



One more note - the links you are using start oeacle at run level 4 and stop it at run level 3. This is fine if you are bring the system up to run level 4 or 5, but a lot of systems are only brought up to run level 3, which means your oracle will never start.

Check your default run level in the /etc/initab file
melvyn burnard
Honored Contributor

Re: run script during server shutdown?

Most servers are booted up to run level 3, so your start script would be in /sbin/rc3.d

Likewise, when shutting down, you go FROM run level 3 TO run level 2, so your Kxxxscript would go in /sbin/rc2.d

As already mentioned there are some good readme's on how to do this available.
My house is the bank's, my money the wife's, But my opinions belong to me, not HP!
Peter A. Berger Jr.
Regular Advisor

Re: run script during server shutdown?

thanks for the tips. however, when I try to create symbolic link I cannot seem to change the permissions.

All of the existing files in the "/sbin/rc3.d" directory have "lrwxr-xr-x" permissions. When I type the command:
"ln -s /home/oracle/startall.sh /sbin/rc3.d/S999oracle"
the "S999oracle" file gets "lrwx------" permissions.

I type "chmod 766 S999oracle" and it doesn't change the permissions.

I "chmod 766 /home/oracle/startall.sh" file and re-created the link and it still doesn't let me change from 700 to 766. I even tried fooling around with the owner and groups. Nothing will let me change the permissions to 766 on the link in "/sbin/rc3.d".

Oh what shall I do?
James R. Ferguson
Acclaimed Contributor

Re: run script during server shutdown?

Hi Peter:

The permissions and/or ownership of a symbolic link are meaningless. The permissions and ownership of the file (or directory) to which the symbolic link points are all that matter!

Regards!

...JRF...
Patrick Wallek
Honored Contributor

Re: run script during server shutdown?

For the startup and shutdown scripts 700 or 750 permissions are fine. You really do NOT want the file to be readable or executable by anyone. You wouldn't want just anyone shutting your DB down would you?

Besides, permission on a link are somewhat meaningless as the permissions on the file you link to will be honored.
Peter A. Berger Jr.
Regular Advisor

Re: run script during server shutdown?

Thanks for the permissions help. I'll be rebooting the server on 10/21/06 @ 08:00hrs ET. I'll update y'all on success/failure after that time.
these forums rock!
Peter A. Berger Jr.
Regular Advisor

Re: run script during server shutdown?

Thanks for the help...your suggestions worked fine...we didn find some instances where the DBA's were not using fully qualified path names (ie: ./script.sh instead of /usr/local/bin/script.sh) so there were minor failures, but overall it worked.