System Administration Guide: Basic Administration

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

  1. Become superuser.

  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—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 
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