Operating System - HP-UX
1754904 Members
3554 Online
108827 Solutions
New Discussion юеВ

Re: run script when system reboot

 
SOLVED
Go to solution
peterchu
Super Advisor

run script when system reboot

I want to start the db automatically everytime when the system reboot , how to set it ? thx
6 REPLIES 6
Michael Tully
Honored Contributor
Solution

Re: run script when system reboot

Firstly you need to create a script in the /sbin/init.d directory for your database. There is a sample file called template that can be used. Once this is created, a symbolic link needs to created in both startup and shutdown run-levels.
(/sbin/rc3.d/K090dbshut and /sbin/rc4.d/S910dbstart)

It is a little difficult giving an example when we don't know what database you have or it may be configured on your system.
Anyone for a Mutiny ?
peterchu
Super Advisor

Re: run script when system reboot

thx reply,

what is mean of K090 and S910 , is it meaningful ? just add K090 + script ( eg. K090myscript )to your said path is OK ? Thx
Michael Tully
Honored Contributor

Re: run script when system reboot

The way a system is setup is that you have the actual scripts in /sbin/init.d

A symbolic link is then created for both the shutdown run level, generally rc3.d (K090) and startup /sbin/rc4.d (S910).
The naming convention is that both of these numbers add up to 1000. (combination of S910 and K090) (this process of the actual run level numbering will vary from site to site.)

The script itself if written correctly that the Kxxx shutsdown the process/package and Sxxx will start it.

Having the script in as Kxxx instead of a link will work, but it is not a standard practise.
Anyone for a Mutiny ?
R. Allan Hicks
Trusted Contributor

Re: run script when system reboot

BTW one thing to watch out for if this is oracle...

Make sure that /etc/oratab is set up correctly. If you can do a dbstart and a dbshut then it is working correctly.

Look at some of the scripts on /sbin/init.d to see how they work.

The standard scripts take one argument. This argument will have a value of:

start_msg
stop_msg
start
stop

start_msg and stop_msg cause the script to print a display on the console. This is typically Starting Oracle, Stopping Oracle. This is what makes the cute little status lines during startup and shutdown

There is usually a case statement in the script that branches on the message values. As I said earlier, the start_msg and stop_msg will branch down and echo the messages on the console.

The start branch will typically do

su - oracle -c dbstart

and the stop branch will be

su - oracle -c dbshut

I've found that I've had to modify the dbshut script so that it does an immediate shutdown. Otherwise, oracle will not shutdown until everyone has logged off.

-Good Luck
"Only he who attempts the absurd is capable of achieving the impossible
Tom Maloy
Respected Contributor

Re: run script when system reboot

And if you are starting up ssh or any other access method, start Oracle AFTER those scripts, because Oracle can take a while to start.

So pick a high S number, like S990, since the startup scripts run in numerical order:
S001
S002
...
S099
S100
...

Tom
Carpe diem!
Bharat Katkar
Honored Contributor

Re: run script when system reboot

Hi,
Have a look at this threads below:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=450287

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=391167

Regards,

You need to know a lot to actually know how little you know