The way system services are started and stopped in the Solaris environment might change in some future release.
The Solaris software environment provides a detailed series of run control (rc) scripts to control run-level changes. Each run level has an associated rc script that is located in the /sbin directory:
rc0
rc1
rc2
rc3
rc5
rc6
rcS
For each rc script in the /sbin directory, there is a corresponding directory named /etc/rcn.d that contains scripts to perform various actions for that run level. For example, /etc/rc2.d contains files that are used to start and stop processes for run level 2.
# ls /etc/rc2.d K03samba* S20sysetup* S72slpd* S88utmpd* K06mipagent* S21perf* S73cachefs.daemon* S89PRESERVE* K07dmi* S30sysid.net* S73nfs.client* S89bdconfig@ K07snmpdx* S40llc2* S74autofs* S90wbem* K16apache* S42ncakmod* S74syslog* S91afbinit* K21dhcp* S47pppd* S74xntpd* S91gfbinit* K26sshd* S69inet* S75cron* S91ifbinit* K27boot.server* S70sckm* S75flashprom* S92volmgt* K28kdc* S70uucp* S75savecore* S93cacheos.finish* K28kdc.master* S71ldap.client* S76nscd* S94ncalogd* K28nfs.server* S71rpc* S77sf880dr* S95IIim* README S71sysid.sys* S80lp* S95svm.sync* S01MOUNTFSYS* S72autoinstall* S80spc* S98efcode* S05RMTMPFILES* S72directory@ S85power* S99audit* S10lu* S72inetsvc* S88sendmail* S99dtlogin* |
The /etc/rcn.d scripts are always run in ASCII sort order. The scripts have names of the form:
[KS][0-9][0-9]*
Files that begin with K are run to terminate (kill) a system service. Files that begin with S are run to start a system service.
Run control scripts are also located in the /etc/init.d directory. These files are linked to corresponding run control scripts in the /etc/rcn.d directories.
The actions of each run control script are summarized in the following section.
The following sections summarize the run control scripts that are used to start and stop system services when you change run levels.
The /sbin/rc0 script runs the /etc/rc0.d scripts to perform the following tasks:
Stops system services and daemons
Terminates all running processes
Unmounts all file systems
The /sbin/rc1 script runs the /etc/rc1.d scripts to perform the following tasks:
Stops system services and daemons
Terminates all running user processes
Unmounts all remote file systems
Mounts all local file systems if the previous run level was S
The /sbin/rc2 script runs the /etc/rc2.d scripts to perform the following tasks, grouped by function:
Local system-related tasks:
Mounts all local file systems if the previous run level was S
Enables disk quotas if at least one file system was mounted with the quota option
Saves temporary editor files in the /usr/preserve directory
Removes any files and subdirectories in the /tmp directory
Starts system activity data collecting, system accounting, and system auditing, if configured
Starts the system logging daemon (syslogd), sets the default dump device, and rotates the /var/adm/messages file
Sets the default scheduling class if the /etc/dispadmin.conf file exists
Starts LP print service (lpsched) if a local printer is configured and cleans up the print queue
Configures power management, if appropriate
Starts the utmpd daemon
Starts the cron and vold daemons
Configures serial device stream
Configures WBEM services
Syncs volumes, if required, and starts the mdmonitord daemon to monitor the physical components of the volumes
Starts the CDE desktop login process, dtlogin, if appropriate
Network service or security-related tasks:
Configures the network interfaces, sets ifconfig netmask, and configures network routing, if appropriate
Starts network service (inetd and rpcbind) daemons
Starts the logical link controller (llc2), if configured
Sets the name service domain name, starts various name services daemons, depending on if the system is configured for a name service, and whether the system is a client or a server
Starts the keyserv, statd, lockd, and xntpd daemons, if appropriate
Mounts all NFS entries
Configures the Solaris Network Cache and Accelerator (NCA) and NCA logging, if appropriate
Starts the Solaris PPP server or client daemons (pppoed or pppd), if configured
Starts LDAP cache manager (ldap_cachemgr), if configured
Starts directory server (slapd) daemon, if configured
Starts DNS (in.named) daemon, if configured
Starts Service Location Protocol (slpd) daemon, if configured
Configures system resource controls and system pools if the /etc/rctladm.conf and /etc/pooladm.conf files exist
Starts the cachefsd, automount, and sendmail daemons, if appropriate
Starts the htt_server process
Install-related tasks:
Configures the boot environment for the Live Upgrade software upon system startup or system shutdown
Checks for the presence of the /etc/.UNCONFIGURE file to see if the system should be reconfigured
Reboots the system from the installation media or a boot server if either /.PREINSTALL or /AUTOINSTALL exists
Hardware-related tasks:
Starts the Sun Fire 15000 key management daemon (sckmd), if appropriate
Starts the Sun Fire 880 Dynamic Reconfiguration daemon (sf880drd), if appropriate
Runs the flash PROM update script
Configures any graphic frame buffers or graphic accelerators
Runs the FCode interpreter daemon (efdaemon), if necessary
Transitions the following services between run-level changes:
Apache (tomcat)
Boot server (in.rarpd), (rpc.bootparamd), or (rpld)
DHCP (in.dhcpd)
Kerberos KDC (krb5kdc ) and Kerberos administration (kadmind)
Mobile IP (mipagent)
NFS server (nfsd), (mountd), (nfslogd)
Samba (smdb) and (nmdb)
Secure shell (sshd)
Solstice Enterprise Agents (dmispd) and (snmpXdmid)
Many of the system services and applications that are started at run level 2 depend on what software is installed on the system.
The /sbin/rc3 script runs the /etc/rc3.d scripts to perform the following tasks:
Starts the Apache server daemon (tomcat), if configured
Starts the DHCP daemon (in.dhcpd), if appropriate
Starts Kerberos KDC (krb5kdc) and Kerberos administration (kadmind) daemons, if configured
Starts Mobile IP daemon (mipagent), if configured
Starts the Samba daemons (smdb and nmdb), if configured
Starts the secure shell daemon (sshd), if appropriate
Starts the Solstice Enterprise Agents (dmispd and snmpXdmid)
Cleans up the /etc/dfs/sharetab file
Starts the NFS server daemons nfsd, mountd, and nfslogd, if appropriate
If the system is a boot server, starts the rarpd, rpc.bootparamd, and rpld daemons
The /sbin/rc5 and /sbin/rc6 scripts run the /etc/rc0.d/K* scripts to perform the following tasks:
Kills all active processes
Unmounts the file systems
The /sbin/rcS script runs the /etc/rcS.d scripts to bring the system up to run level S. The following tasks are performed by these scripts:
Establishes a minimal network
Checks and mounts root (/), /usr, /tmp, /var, /var/adm, and /var/run file systems.
Sets the system name
Mounts pseudo file systems (/proc and /dev/fd)
Rebuilds the device entries for reconfiguration boots
Checks and mounts other file systems to be mounted in single-user level
The way system services are started and stopped in Solaris environment might change in some future release.
One advantage of having individual scripts for each run level is that you can run scripts in the /etc/init.d directory individually to stop system services without changing a system's run level.
Become superuser.
Stop the system service.
# /etc/init.d/filename stop |
Restart the system service.
# /etc/init.d/filename start |
Verify that the service has been stopped or started.
# pgrep -f service |
For example, you can stop the NFS server daemons by typing the following:
# /etc/init.d/nfs.server stop # pgrep -f nfs # |
Then, you can restart the NFS server daemons by typing the following:
# /etc/init.d/nfs.server start # pgrep -f nfs 341 343 347 345 # pgrep -f nfs -d, | xargs ps -fp UID PID PPID C STIME TTY TIME CMD daemon 341 1 0 Aug 21 ? 0:00 /usr/lib/nfs/statd root 343 1 0 Aug 21 ? 0:00 /usr/lib/nfs/lockd root 347 1 0 Aug 21 ? 0:41 /usr/lib/nfs/nfsd root 345 1 0 Aug 21 ? 0:02 /usr/lib/nfs/mountd |
The way system services are started and stopped in the Solaris environment might change in some future release.
If you want to add a run control script to start and stop a service, copy the script into the /etc/init.d directory. Then, create links in the rcn.d directory where you want the service to start and stop.
See the README file in each /etc/rcn.d directory for more information on naming run control scripts. The following procedure describes how to add a run control script.
Become superuser.
Add the script to the /etc/init.d directory.
# cp filename /etc/init.d # chmod 0744 /etc/init.d/filename # chown root:sys /etc/init.d/filename |
Create links to the appropriate rcn.d directory.
# cd /etc/init.d # ln filename /etc/rc2.d/Snnfilename # ln filename /etc/rcn.d/Knnfilename |
Verify that the script has links in the specified directories.
# ls /etc/init.d/ /etc/rc2.d/ /etc/rcn.d/ |
The following example shows how to add a run control script for the xyz service.
# cp xyz /etc/init.d # chmod 0744 /etc/init.d/xyz # chown root:sys /etc/init.d/xyz # cd /etc/init.d # ln xyz /etc/rc2.d/S100xyz # ln xyz /etc/rc0.d/K100xyz # ls /etc/init.d /etc/rc2.d /etc/rc0.d |
You can disable a run control script by renaming it with an underscore (_) at the beginning of the file name. Files that begin with an underscore or dot are not executed. If you copy a file by adding a suffix to it, both files will be run.
Become superuser.
Rename the script by adding an underscore (_) to the beginning of the new file.
# cd /etc/rcn.d # mv filename _filename |
Verify that the script has been renamed.
# ls _* # _filename |
The following example shows how to rename the S100datainit script.
# cd /etc/rc2.d # mv S100datainit _S100datainit # ls _* # _S100datainit |