HP-UX HB v13.00 Ch-03 - System Startup
HP-UX Handbook – Rev 13.00 Page 9 (of 14)
Chapter 03 System Startup
October 29, 2013
Sequencer Script - /sbin/rc
The job of the sequencer script /sbin/rc is to invoke the individual startup scripts in
/sbin/init.d/. However, /sbin/rc does not invoke these scripts directly, but rather through a
series of symbolic links (Execution Script Links) in the /sbin/rc?.d/ directories. For example,
if your system is booting to run level 3 (invoking all services, including CDE), then /sbin/rc
will invoke all the scripts (symbolic links) in the /sbin/rc2.d/, and /sbin/rc3.d/ directories.
The names of these links in /sbin/rc?d/ directories begin with a K or an S. /sbin/rc will
invoke the ones that begin with a K using the 'stop' parameter and the ones that begin with an S
using the 'start' parameter. /sbin/rc does not really care about the serial numbers in the link
names after the K or S; they are there so that you can configure the order in which the scripts are
run, since they run in alphanumeric order. If you don't care when your software starts, use serial
number 900 for an S file and 100 for a K file, which are guaranteed not to conflict with existing
serial numbers.
The /sbin/rc script is the one that interprets the exit codes from the script, so if you write your
own script make sure to get the exit codes correct. At boot time, /sbin/rc creates a checklist on
the console, filling in each box with OK, FAIL, or N/A corresponding to exit codes 0, 1, or 2
from the script. If the script exits with code 3 or something other than 0, 1, or 2, /sbin/rc could
reboot the system. So don't use that exit code spuriously.
The Sequencer /sbin/rc is invoked upon entering a new run level via the init N command
(where N equals 0-6). The script /sbin/rc is typically invoked by the corresponding entry in the
file /etc/inittab as follows:
sqnc:123456:wait:/sbin/rc </dev/console >/dev/console 2>&1
If a transition from a lower to a higher run level (i.e., init state) occurs, the start scripts for the
new run level and all intermediate levels between the old and new level are executed. If a
transition from a higher to a lower run level occurs, the kill scripts for the new run level and all
intermediate levels between the old and new level are executed.
If a start script link (e.g., /sbin/rc2.d/S730cron) in sequencer N has a stop action, the
corresponding kill script should be placed in sequencer N-1 (e.g., /sbin/rc1.d/K270cron).
Actions started in level N should be stopped in level N-1. This way, a system shutdown (e.g.,
transition from level 3 directly to level 0) will result in all subsystems being stopped.