HP-UX Reference (11i v1 00/12) - 1M System Administration Commands N-Z (vol 4)

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man1m/naaagt.1m
________________________________________________________________
___ ___
r
rc(1M) rc(1M)
NAME
rc - general purpose sequencer invoked upon entering new run level
SYNOPSIS
/sbin/rc
DESCRIPTION
The rc shell script is the general sequencer invoked upon entering a new run level via the init N com-
mand (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
/sbin/rc
is the startup and shutdown sequencer script. There is only one sequencer script and it han-
dles all of the sequencer directories. This script sequences the scripts in the appropriate sequencer direc-
tories in alphabeticalorder as defined by the shell and invokes them as either startup or kill scripts.
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/rcN.d/S123test) in sequencer N has a stop action, the correspond-
ing kill script should be placed in sequencer N-1 (e.g., /sbin/rcN-1.d/K200test).
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.
Start and Kill Scripts
In many cases, a startup script will have both a start and a kill action. For example, the inetd script starts
the Internet daemon in the start case, and kills that process in the stop case. Instead of two separate
scripts, only one exists, which accepts both the
start and stop arguments and executes the correct code.
In some cases, only a start action will be applicable. If this is the case, and if the
stop action is specified,
the script should produce a usage message and exit with an error. In general, scripts should look at their
arguments and produce error messages if bad arguments are present. When a script executes properly, it
must exit with a return value of zero. If an error condition exists, the return value must be nonzero.
Naming Conventions
The startup and shutdown scripts (referred to as startup scripts hereafter) exist in the
/sbin/init.d
directory, named after the subsystem they control. For example, the /sbin/init.d/cron
script con-
trols starting up the
cron daemon. The contents of sequencer directories consist of symbolic links to
startup scripts in /sbin/init.d . These symbolic links must follow a strict naming convention, as noted
in the various fields of this example:
/sbin/rc2.d/S060cron
where the fields are defined as follows:
rc2.d The sequencer directory is numbered to reflect the run level for which its contents will
be executed. In this case, start scripts in this directory will be executed upon entering
run level 2 from run level 1, and kill scripts will be executed upon entering run level 2
from run level 3.
S The first character of a sequencer link name determines whether the script is exe-
cuted as a start script (if the character is S), or as a kill script (if the character is
K).
060 A three digit number is used for sequencing scripts within the sequencer directory.
Scripts are executed by type (start or kill) in alphabeticalorder as defined by the shell.
Although it is not recommended, two scripts may share the same sequence number.
cron The name of the startup script follows the sequence number. The startup script name
must be the same name as the script to which this sequencer entry is linked. In this
example, the link points to /sbin/init.d/cron.
Note that short file name systems require file names of 14 or less characters. This
means that the fourth field is limited to 10 or fewer characters.
Scripts are executed in alphabetical order. The entire file name of the script is used
for alphabeticalordering purposes.
Section 1M688 1 HP-UX Release 11i: December 2000
___
___