Operating System - HP-UX
1834406 Members
1414 Online
110067 Solutions
New Discussion

Unix system Startup & Kill run level scripts

 
SOLVED
Go to solution
Phani_4
Frequent Advisor

Unix system Startup & Kill run level scripts

Hi,

In one of my HP-UX server, i observed that there are some Killing scripts missing for Starting scripts...Is this abnormal ?

Apart from the Startup & Kill naming convention (for ex: S & K ), is there will be any difference between Startup script & Kill script ( the shell script inside the file ) ?

Please give me some valuable info on this.

Regards,
Phani
5 REPLIES 5
John Carr_2
Honored Contributor

Re: Unix system Startup & Kill run level scripts

Hi

this happens, I usually rename or remove starup scripts for services not required as part of the hardening process. S and K are naming conventions what is is in the script will happen regardless of the name and of course it only happens when the script is called by the correct name.

:-) john.
Patrick Wallek
Honored Contributor
Solution

Re: Unix system Startup & Kill run level scripts

Actually the start and kill scripts are one and the same. If you look at the S* and K* files, you will notice that they are links to scripts in /sbin/init.d, at least about 99% of the time. The scripts in /sbin/init.d are the real workhorses. There are sections in those scripts that control the startup and shutdown of the various products and services.

Open up one of the scripts and take a look at it and you'll see what I mean.

When HP-UX starts up, or shuts down / reboots, the init command parses through the scripts in each /sbin/rc?.d run level directory. If it is starting up each script gets executed with a 'start' as the parameter for the script (/sbin/rc2.d/S500inetd start to start the inetd daemon). When the system is shuttind down, the same script gets called, except there is a 'stop' argument (/sbin/rc1.d/K500inetd stop to stop the inetd daemon).

Now it is possible for some third party products, or home grown applications, that you may have a start script and not a kill script. If you don't care the the process for an application just gets killed when the machine shuts down, then you may not have put one in. It is not adviseable, but is possible. I generally like to keep the S and K scripts in sync as it makes things easier to manage.
A. Clay Stephenson
Acclaimed Contributor

Re: Unix system Startup & Kill run level scripts

In MOST cases if there is a start script for run-level N then there should be a kill script executed upon transition to run-level N-1 but certainly not all. For example, it is common to remove temporary files of startup but to do nothing on shutdown. One often sees license daemons started but simply allowed to die on shutdown.

The convention (and its nothing more than that) is that id the startup script is named SnnnXXX and the kill script is named KNNNXXX then nnn + NNN should equal 1000. This tends to correctly order the startup and shutdown. Also both the startup and kill scripts should be symbolic links to the actual script in /sbin/init.d.

The same script is almost always used for both startup and kill and the difference in behavior is controlled inside a case statement depneding upon whether a 'stop', 'start', 'start_msg', or 'stop_msg' argument was supplied to the script.
If it ain't broke, I can fix that.
Pete Randall
Outstanding Contributor

Re: Unix system Startup & Kill run level scripts

Phani,

To answer your question about the difference between startup and kill scripts: there is no difference. If you look closely, you will see that they are merely links to a /sbin/init.d/ script. During startup, all the rc?.d directories are parsed and all the S* scripts invoke their corresponding /sbin/init.d script with a "start" argument. During shutdown, the reverse is true. All the K* scripts invoke the corresponding /sbin/init.d script with a "stop" argument. Any difference comes from the way the /sbin/init.d script handles the two arguments.


Pete

Pete
Phani_4
Frequent Advisor

Re: Unix system Startup & Kill run level scripts

Hi All,

Great explaination..Very much clear :)
Thanks alot for your information.

Thanks,
Regards,
Phani