# phpman > man > sv(8)

[sv(8)](https://www.chedong.com/phpMan.php/man/sv/8/markdown)                                  System Manager's Manual                                 [sv(8)](https://www.chedong.com/phpMan.php/man/sv/8/markdown)



## NAME
       sv - control and manage services monitored by [**runsv**(8)](https://www.chedong.com/phpMan.php/man/runsv/8/markdown)

## SYNOPSIS
       **sv** [-v] [-w _sec_] _command_ _services_

       **/etc/init.d/**_service_ [-w _sec_] _command_

## DESCRIPTION
       The **sv** program reports the current status and controls the state of services monitored by the
       [**runsv**(8)](https://www.chedong.com/phpMan.php/man/runsv/8/markdown) supervisor.

       _services_ consists of one or more arguments, each argument naming a directory _service_ used  by
       [**runsv**(8)](https://www.chedong.com/phpMan.php/man/runsv/8/markdown).   If  _service_ doesn't start with a dot or slash and doesn't end with a slash, it is
       searched in the default services directory _/etc/service/_, otherwise relative to  the  current
       directory.

       _command_  is  one  of  up, down, status, once, pause, cont, hup, alarm, interrupt, 1, 2, term,
       kill, or exit, or start, stop, restart, shutdown,  force-stop,  force-reload,  force-restart,
       force-shutdown.

       The  **sv**  program  can  be sym-linked to _/etc/init.d/_ to provide an LSB init script interface.
       The _service_ to be controlled then is specified by the base name of the ``init script''.

## COMMANDS
       **status** Report the current status of the service, and the appendant log service if  available,
              to standard output.

       **up**     If the service is not running, start it.  If the service stops, restart it.

       **down**   If the service is running, send it the TERM signal, and the CONT signal.  If ./run ex‐
              its, start ./finish if it exists.  After it stops, do not restart service.

       **once**   If the service is not running, start it.  Do not restart it if it stops.

### pause cont hup alarm interrupt quit 1 2 term kill
              If the service is running, send it the STOP, CONT, HUP, ALRM, INT, QUIT,  USR1,  USR2,
              TERM, or KILL signal respectively.

       **exit**   If  the  service  is  running,  send  it the TERM signal, and the CONT signal.  Do not
              restart the service.  If the service is down, and no log service exists, [**runsv**(8)](https://www.chedong.com/phpMan.php/man/runsv/8/markdown)  ex‐
              its.   If  the  service is down and a log service exists, [**runsv**(8)](https://www.chedong.com/phpMan.php/man/runsv/8/markdown) closes the standard
              input of the log service and waits for it to terminate.  If the log service  is  down,
              [**runsv**(8)](https://www.chedong.com/phpMan.php/man/runsv/8/markdown) exits.  This command is ignored if it is given to an appendant log service.

       **sv** actually looks only at the first character of these _command_s.

### Commands compatible to LSB init script actions
       **status** Same as _status_.

       **start**  Same  as _up_, but wait up to 7 seconds for the command to take effect.  Then report the
              status or timeout.  If the script _./check_ exists in the  service  directory,  **sv**  runs
              this  script  to  check whether the service is up and available; it's considered to be
              available if _./check_ exits with 0.

       **stop**   Same as _down_, but wait up to 7 seconds for the service to become  down.   Then  report
              the status or timeout.

       **reload** Same as _hup_, and additionally report the status afterwards.

### restart
              Send  the commands _term_, _cont_, and _up_ to the service, and wait up to 7 seconds for the
              service to restart.  Then report the status or timeout.  If the script _./check_  exists
              in  the  service directory, **sv** runs this script to check whether the service is up and
              available again; it's considered to be available if _./check_ exits with 0.

### shutdown
              Same as _exit_, but wait up to 7 seconds for the [**runsv**(8)](https://www.chedong.com/phpMan.php/man/runsv/8/markdown) process  to  terminate.   Then
              report the status or timeout.

### force-stop
              Same  as  _down_,  but wait up to 7 seconds for the service to become down.  Then report
              the status, and on timeout send the service the _kill_ command.

### force-reload
              Send the service the _term_ and _cont_ commands, and wait up to 7 seconds for the  service
              to restart.  Then report the status, and on timeout send the service the _kill_ command.

### force-restart
              Send the service the _term_, _cont_ and _up_ commands, and wait up to 7 seconds for the ser‐
              vice to restart.  Then report the status, and on timeout send  the  service  the  _kill_
              command.   If  the script _./check_ exists in the service directory, **sv** runs this script
              to check whether the service is up and available again; it's considered to  be  avail‐
              able if _./check_ exits with 0.

### force-shutdown
              Same  as  _exit_,  but wait up to 7 seconds for the [**runsv**(8)](https://www.chedong.com/phpMan.php/man/runsv/8/markdown) process to terminate.  Then
              report the status, and on timeout send the service the _kill_ command.

### try-restart
              if the service is running, send it the _term_ and _cont_ commands, and wait up to  7  sec‐
              onds for the service to restart.  Then report the status or timeout.


### Additional Commands
       **check**  Check  for the service to be in the state that's been requested.  Wait up to 7 seconds
              for the service to reach the requested state, then report the status or  timeout.   If
              the requested state of the service is _up_, and the script _./check_ exists in the service
              directory, **sv** runs this script to check whether the service is up  and  running;  it's
              considered to be up if _./check_ exits with 0.

## OPTIONS
### -v
              the command to take effect.  Then report the status or timeout.

### -w

## ENVIRONMENT
       **SVDIR**  The environment variable $SVDIR overrides the  default  services  directory  _/etc/ser__‐
              _vice/_.

       **SVWAIT** The environment variable $SVWAIT overrides the default 7 seconds to wait for a command
              to take effect.  It is overridden by the -w option.

## EXIT CODES
       **sv** exits 0, if the _command_ was successfully sent to all _services_, and,  if  it  was  told  to
       wait, the _command_ has taken effect to all services.

       For  each  _service_  that  caused an error (e.g. the directory is not controlled by a [**runsv**(8)](https://www.chedong.com/phpMan.php/man/runsv/8/markdown)
       process, or **sv** timed out while waiting), **sv** increases the exit code  by  one  and  exits  non
       zero.  The maximum is 99.  **sv** exits 100 on error.

       If  **sv** is called with a base name other than **sv**: it exits 1 on timeout or trouble sending the
       command; if the _command_ is **status**, it exits 3 if the service is down, and 4 if the status  is
       unknown; it exits 2 on wrong usage, and 151 on error.

## SEE ALSO
       [runsv(8)](https://www.chedong.com/phpMan.php/man/runsv/8/markdown), [chpst(8)](https://www.chedong.com/phpMan.php/man/chpst/8/markdown), [svlogd(8)](https://www.chedong.com/phpMan.php/man/svlogd/8/markdown), [runsvdir(8)](https://www.chedong.com/phpMan.php/man/runsvdir/8/markdown), [runsvchdir(8)](https://www.chedong.com/phpMan.php/man/runsvchdir/8/markdown), [runit(8)](https://www.chedong.com/phpMan.php/man/runit/8/markdown), [runit-init(8)](https://www.chedong.com/phpMan.php/man/runit-init/8/markdown)

       <http://smarden.org/runit/>

## AUTHOR
       Gerrit Pape <<pape@smarden.org>>



                                                                                               [sv(8)](https://www.chedong.com/phpMan.php/man/sv/8/markdown)
