JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
System Administration Guide: Basic Administration     Oracle Solaris 11 Express 11/10
search filter icon
search icon

Document Information

Preface

1.  Managing User Accounts and Groups (Overview)

2.  Managing User Accounts and Groups (Tasks)

3.  Introduction to Shutting Down and Booting a System

4.  Shutting Down and Booting a System (Overview)

5.  Shutting Down a System (Tasks)

6.  Modifying Oracle Solaris Boot Behavior (Tasks)

7.  Booting an Oracle Solaris System (Tasks)

8.  Troubleshooting Booting an Oracle Solaris System (Tasks)

9.  Managing the Oracle Solaris Boot Archives (Tasks)

10.  x86: GRUB Based Booting (Reference)

11.  Managing Services (Overview)

12.  Managing Services (Tasks)

Managing Services (Task Map)

Monitoring SMF Services

How to List the Status of a Service

How to Show Which Services Are Dependent on a Service Instance

How to Show Which Services a Service Is Dependent On

Managing SMF Services (Task Map)

Managing SMF Services

Using RBAC Rights Profiles With SMF

How to Disable a Service Instance

How to Enable a Service Instance

How to Restart a Service

How to Restore a Service That Is in the Maintenance State

How to Revert to Another SMF Snapshot

How to Create an SMF Profile

How to Apply an SMF Profile

Changing Services Offered to the Network with generic*.xml

Configuring SMF Services

How to Modify a Service

How to Change an Environment Variable for a Service

How to Change a Property for an inetd Controlled Service

How to Modify a Command-Line Argument for an inetd Controlled Service

How to Convert inetd.conf Entries

Using Run Control Scripts (Task Map)

Using Run Control Scripts

How to Use a Run Control Script to Stop or Start a Legacy Service

How to Add a Run Control Script

How to Disable a Run Control Script

Troubleshooting the Service Management Facility

Debugging a Service That Is Not Starting

How to Repair a Corrupt Repository

How to Boot Without Starting Any Services

How to Force a sulogin Prompt If the system/filesystem/local:default Service Fails During Boot

Index

Using Run Control Scripts

How to Use a Run Control Script to Stop or Start a Legacy Service

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.

  1. Become an administrator or assume a role that includes the Service Management rights profile.

    For more information, see How to Obtain Administrative Rights in System Administration Guide: Security Services

  2. Stop the system service.
    # /etc/init.d/filename 
    stop
  3. Restart the system service.
    # /etc/init.d/filename 
    start
  4. Verify that the service has been stopped or started.
    # pgrep -f service

Example 12-15 Using a Run Control Script to Stop or Start a 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
101773
101750
102053
101748
101793
102114
# pgrep -f nfs -d, | xargs ps -fp
     UID    PID   PPID   C    STIME TTY         TIME CMD
  daemon 101748      1   0   Sep 01 ?           0:06 /usr/lib/nfs/nfsmapid
  daemon 101750      1   0   Sep 01 ?          26:27 /usr/lib/nfs/lockd
  daemon 101773      1   0   Sep 01 ?           5:27 /usr/lib/nfs/statd
    root 101793      1   0   Sep 01 ?          19:42 /usr/lib/nfs/mountd
  daemon 102053      1   0   Sep 01 ?        2270:37 /usr/lib/nfs/nfsd
  daemon 102114      1   0   Sep 01 ?           0:35 /usr/lib/nfs/nfs4cbd

How to Add a Run Control Script

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/rc n.d directory for more information on naming run control scripts. The following procedure describes how to add a run control script.

  1. Become an administrator or assume a role that includes the Service Management rights profile.

    For more information, see How to Obtain Administrative Rights in System Administration Guide: Security Services

  2. 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
  3. Create links to the appropriate rc n.d directory.
    # cd /etc/init.d
    # ln filename /etc/rc2.d/Snnfilename
    # ln filename /etc/rcn.d/Knnfilename
  4. Verify that the script has links in the specified directories.
    # ls /etc/init.d/*filename /etc/rc2.d/*filename /etc/rcn.d/*filename

Example 12-16 Adding a Run Control Script

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/S99xyz
# ln xyz /etc/rc0.d/K99xyz
# ls /etc/init.d/*xyz /etc/rc2.d/*xyz /etc/rc0.d/*xyz

How to Disable a Run Control Script

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.

  1. Become an administrator or assume a role that includes the Service Management rights profile.

    For more information, see How to Obtain Administrative Rights in System Administration Guide: Security Services

  2. Rename the script by adding an underscore (_) to the beginning of the new file.
    # cd /etc/rcn.d
    # mv filename_filename
  3. Verify that the script has been renamed.
    # ls _*
    _filename

Example 12-17 Disabling a Run Control Script

The following example shows how to rename the S99datainit script.

# cd /etc/rc2.d
# mv S99datainit _S99datainit
# ls _*
_S99datainit