Operating System - HP-UX
1832203 Members
2526 Online
110039 Solutions
New Discussion

Running script at the boot time of server

 
SAMIR SHAH_1
Contributor

Running script at the boot time of server

Hi,

We have HP K/360/2 server. I want to run some of my shell scripts immediately after the server starts.

How can I do this?

Pl. assist.

Thanks.

2 REPLIES 2
Maureen Gunkel
Trusted Contributor

Re: Running script at the boot time of server

Hi,
I know you need to put them in the appropriate rc{1-5}.d directory. Maybe this link will help

http://forums.itrc.hp.com/cm/QuestionAnswer/1,1150,0xe8f0f841489fd4118fef0090279cd0f9,00.html

HTH,
Mo
No matter where you go, there you are.
Dan Hetzel
Honored Contributor

Re: Running script at the boot time of server

Hi Samir,

At boot time, all scripts residing starting with the letter S (for start) located in directories /sbin/rc?.d are run in alphabetical order.
The last directory from which scripts will be run depends on your init level.(for example /sbin/rc3.d for init level 3)

The default boot level will have an entry called 'initdefault' in file /etc/inittab (normally 3)

All files in /sbin/rc?.d are symbolic links to files in /sbin/init.d. Those files have more meaningful names.

To control the execution of those scripts, they source files with some variable definitions located in /etc/rc.config.d

All the scripts in /sbin/init.d have a start and a stop entry, meaning that depending the argument given, the same script can be used a system startup or shutdown.
The shutdown scripts are run in the same way as the startup scripts, in reverse alphabetic order. They have a name staring with a K (for kill).

An example:
starting nfs_client will be done with file S430nfs_client located in /etc/rc2.d
This means that nfs_client will be enabled at init level 2 (rc2.d).
When shutting down, going from level x down to 0, the nfs_client will be stopped when script /sbin/rc1.d/K570nfs_client. This one is executed when leaving level 2, that's why it is located in rc1.d.

When nfs_client is started, the file /etc/rc.config.d/nfsconf is sourced and some variables are defined.

If you want to add scripts starting automatically during system boot, you could simply follow the same principle:

one file in /sbin/init.d
2 files (one for startup, one for shutdown) in the /etc/rc?.d directories, starting with S and K (symbolic links to the file in /sbin/init.d)
one file in /etc/rc.config.d with some variables defined (this one isn't mandatory)

You simply need to define when your script is run, and make sure all necessary resources are available, for example, don't rely on /usr/bin/csh if the /usr filesystem isn't mounted yet or dont try accessing the network if it's not up and running.

Hoping this was clear enough,

Best regards,

Dan


Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com