Information Technology Reference
In-Depth Information
In addition, the
shutdown
command provides a user-friendly warning mes-
sage and grace period to allow users to close files and log out before the sys-
tem changes run levels.
Run Control (rc) Scripts
As previously stated, every run level (except 4) has an entry in the
/etc/
inittab
file that identifies an
rc
program to execute. In addition, each run
level has a directory associated with it.
The directory contains
rc
scripts that should be executed by the
rc
program
to start or stop processes and services when that run level becomes the cur-
rent one. These
rc
program and
rc
script directories use a standard naming
convention based on the run level:
For run level 0, the
rc
program is
/etc/rc0
, and
/etc/rc0.d
is the rc
script directory.
➤
For run level 1, the
rc
program is
/etc/rc1
, and
/etc/rc1.d
is the
rc
script directory.
➤
For run levels 2, 3, and s, the same naming convention applies.
➤
Run levels 5 and 6 do not have separate
rc
directories, but rather use the
run level 0
rc
directory.
➤
Typically, both the
rc
program and the scripts under the
rc
script directories
are referred to as
rc
scripts. Referring to the script called directly from the
/etc/inittab
as the
rc
program helps avoid confusion.
The
rc
scripts are shell scripts (typically Bourne shell scripts) that have been
written to start and stop various processes and services. An
rc
script is usual-
ly written in two portions: a start portion and a stop portion. As their names
imply, the start portion is executed to start a service, whereas the stop por-
tion is called to stop a service. This allows a single script to control the serv-
ice. When the
rc
script is called by the
rc
program, it provides either a start
or a stop command-line argument to the
rc
script, depending on whether the
service should be started or stopped at a particular run level. The decision to
start or stop a particular service is based on the name of the
rc
script in the
appropriate
rc
directory.
For example, the standard Unix utility to execute maintenance commands
automatically is the
cron
program. It is usually started at run level 2 and
stopped at run levels 0, 1, 5, 6, and s. To start
cron
at run level 2, the
cron rc
script is copied (or linked) into
/etc/rc2.d
and given the name S75cron. The