Understanding Solaris runtime control scripts

Home -> UNIX -> Solaris -> System administration

16867 views

From the computer of: qmchenry (337 recipes)
Created: Oct 03, 2003     Updated: Oct 11, 2004


2 comments:
View all comments

Add a comment

Add to:
Add to stumbleuponAdd to del.icio.usDigg itAdd to FURL

Runtime control scripts are responsible for starting and stopping services when the system changes run levels such as during boot and shutdown. These scripts reside in the rc#.d directories where the # sign is replaced by the run level, such as rc2.d, rc3.d, and rc0.d.

Well written runtime control scripts should accept at least start and stop as runtime parameters and may optionally accept additional parameters such as restart and status. When a runtime control script runs with a start parameter, it starts the processes for which it is responsible. Likewise, the stop parameter causes the script to terminate those processes.

Inside the runtime control directories are a numer of runtime control scripts starting with uppercase K or S followed by two numbers. As the system changes its run level, scripts in the corresponding directory are run in sorted order so a script starting with K00 will run before K99 which will run before S00. A script starting with the letter K is a kill script and will be run with a stop parameter and S scripts will be run with a start parameter. In this manner, the same script can be used to start and stop processes.

It is common to place a generic script, newservice for example, in /etc/init.d and then create logical links to that script in the appropriate rc#.d directory preceeded with a suitable combination of K or S and number. For example, to create an early kill script in rc0.d for an rc script newservice located in /etc/init.d, run as superuser:

cd /etc/rc0.d
ln -s ../init.d/newservice K05newservice


When you shutdown or restart the system you change its run level to 6 or 5, respectively. There are no /etc/rc5.d or /etc/rc6.d directories. Since changing to run level 0 (openboot prompt) involves the same procedure as shutting down or restarting, run levels 5 and 6 share the /etc/rc0.d directory. It is important to include kill scripts for services such as databases that could be corrupted if they were not properly shut down .

For an example of a runtime control script, see the recipe Create a basic Solaris runtime control script

Subscribe to the Tech-Recipes Newsletter

You can get tips like this delivered in your email every week!

Enter your Email

We will never, ever sell your email address or spam you.




2 Recipe comments: View comments

Understanding Solaris runtime control scripts by Anonymous
Re: Understanding Solaris runtime control scripts by qmchenry



Related recipes:

  Create a basic Solaris runtime control script
  Set the ethernet MAC address in Solaris
  Prevent Solaris core files creation with coreadm
  Configure Solaris for DNS resolution of hostnames
  Solaris 10: connect or login to zone console
  Change BootPROM settings from the Solaris command line
  Change Solaris DNS client settings
  Solaris 10: shutdown or stop a zone
  Solaris Processor Info
  Solaris 10: enable NFS server

 

Sponsored links

 

Login

Nickname

Password

Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.