Operating System - HP-UX
1846140 Members
4990 Online
110254 Solutions
New Discussion

run script when system root

 
eric_204
Frequent Advisor

run script when system root

I would like to run a script when everytime the HP UX 11.0 is reboot , what is the simplest way to do it ? thx.
6 REPLIES 6
Graham Cameron_1
Honored Contributor

Re: run script when system root

There is a standard way to do this, see "man rc".

Basically it requires that you copy the script into /sbin/init.d, and then put a symbolic link to a file in /etc/rc2.d or /etc/rc3.d (depending on which run level you want your script to run at).

NB scripts put here are expected to adhere to certain conventions, there is a template (/sbin/init.d/template) - copy it and follow the instructions inside.

-- Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
Bernhard Mueller
Honored Contributor

Re: run script when system root

Hi,

this is what the scripts in /sbin/init.d do
for each there should be a link in /sbin/rcX.d (where X is the run level) named S###_scriptname like /sbin/rc1.d/S500swap_start -> /sbin/init.d/swap_start
for startup

or /sbin/rcX.d/K###myscript -> /sbin/init.d/myscript
for shutdown

Note that you need to include a PATH in those scripts or enter executables with full path.

Regards,
Bernhard
eric_204
Frequent Advisor

Re: run script when system root

thx reply , another question , how can I change the default run level for my system ? thx.
Mister_Z
Frequent Advisor

Re: run script when system root

try:

#init

Regards,
I work for HP
Graham Cameron_1
Honored Contributor

Re: run script when system root

The suggestion from Juan will change your current level, but not the default.

To change the default, modify /etc/inittab, line beginning init, eg

init:3:initdefault:

see man inittab, and be careful!

-- Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
eric_204
Frequent Advisor

Re: run script when system root

Hi Bernhard Mueller ,

i use run level 3 in my HP UX 11 , i only found the files ( S100nfs.server , S200tps.rc , S990dtlogin.rc ) in the path /sbin/rc3.d , do u mean create a file such as db_start in this path , and add the script to this file ? thx.