Solaris Run Control Scripts
Solaris run control (rc) scripts are used to start and stop processes at boot up and shutdown.
SunOS 4.x
For legacy users, SunOS 4.x (BSD style) rc scripts are located in the /etc
directory and start with rc:
- /etc/inittab — defines run levels and actions
- /etc/rc — main system startup script
- /etc/rc.boot — First rc script run at boot up
- /etc/rc.local — Local daemon and application startup script (portmapper, nis, rpc processes)
Solaris 2.x
With Solaris 2.x, the run control scripts conform to the ATT/SVR4 standard).
Files and Directories
Solaris rc scripts are separated into directories that represent run levels.
- /etc/inittab — defines run levels and actions
- /etc/init.d — rc script storage shed
- /etc/rcS — single user startup (linked to /sbin/rcS)
- /etc/rc0 — brings the system down (linked to /sbin/rc0
- /etc/rc1 — bring system down to single user mode (linked to /sbin/rc1)
- /etc/rc2 — multi-user start-up (linked to /sbin/rc2)
- /etc/rc3 — starts and exports network services (linked to /sbin/rc3)
- /etc/rc5 — powerdown the system (linked to /sbin/rc5)
- /etc/rc6 — reboots the system (linked to /sbin/rc6)
- /etc/rcS.d — contains scripts to be run by /etc/rcS
- /etc/rc0.d — contains scripts to be run by /etc/rc0
- /etc/rc1.d — contains scripts to be run by /etc/rc1
- /etc/rc2.d — contains scripts to be run by /etc/rc2
- /etc/rc3.d — contains scripts to be run by /etc/rc3
rc script file formats
rc scripts are preceded with an S
or a K
. S scripts are start scripts and K scripts are kill scripts.
rc script syntax
rc scripts are generally written with a case statement that separate start and stop commands. this enables you to link a script to Sscript and Kscript. the /etc/rc?
will look for the S or K and issue a start or stop to the script.
For example: /etc/init.d/myscript
can be linked to /etc/rc3.d/Smyscript
and /etc/rc3.d/Kmyscript
# cat /init.d/myscript #!/sbin/sh case "$1" in 'start') echo "starting myscript" /usr/sbin/myscript start ;; 'stop') echo "stopping myscript" /usr/sbin/myscript stop ;; *) echo "Usage: $0 { start | stop }" exit 1 esac exit 0 # ln -s /etc/init.d/myscript /etc/rc3.d/S99myscript # ln -s /etc/init.d/myscript /etc/rc3.d/K99myscript