START-STOP-DAEMON(8)

NAME
start-stop-daemon - ensures that daemons start and stop

SYNOPSIS
start-stop-daemon -S, --start daemon [--] [arguments]
start-stop-daemon -K, --stop daemon
start-stop-daemon -s, --signal signal daemon

DESCRIPTION
start-stop-daemon provides a consistent method of starting, stopping and signaling daemons. If neither -K, --stop nor -s, --signal are provided, then we assume we are starting the daemon. If a daemon cannot background by itself, nor create a pidfile, start-stop-daemon can do it for the daemon in a secure fashion.

If start-stop-daemon is used in an OpenRC service, then OpenRC can in turn check to see if the daemon is still running. If not, then the service is marked as crashed.

Here are the options to specify the daemon and how it should start or stop:

-x, --exec daemon
    The daemon we start or stop. If this option is not specified, then the first non option argument is used.

-p, --pidfile pidfile
    When starting, we expect the daemon to create a valid pidfile within a reasonable amount of time. When stopping we only stop the first pid listed in the pidfile.

-n, --name name
    Match the process name instead of a pidfile or executable.

-i, --interpreted
    When matching process name, we should ensure that the correct interpreter is also matched. So if the daemon foo starts off like so
        #!/usr/bin/perl -w
    then start-stop-daemon matches the process
        /usr/bin/perl -w foo
    If an interpreted daemon changes its process name then this won't work.

-u, --user user[:group]
    Start the daemon as the user and update $HOME accordingly or stop daemons owned by the user. You can optionally append a group name here also.

-t, --test
    Print the action(s) that would be taken, but don't actually do anything. The return value is set as if the command was taken and worked.

-v, --verbose
    Print the action(s) that are taken just before doing them.

-q, --quiet
    Run quietly (repeat to suppress errors).

-P, --progress
    Echo a . to the console for each second elapsed whilst waiting.

These options are only used for starting daemons:

-a, --startas name
    Change the process name of the daemon to name. This just changes the first argument passed to the daemon.

-b, --background
    Force the daemon into the background. Some daemons don't create pidfiles, so a good trick is to get the daemon to run in the foreground, and use the this option along with -m, --make-pidfile to create a working pidfile.

-d, --chdir path
    chdir to this directory before starting the daemon.

-r, --chroot path
    chroot to this directory before starting the daemon. All other paths, such as the path to the daemon, chdir and pidfile, should be relative to the chroot.

-c, --chuid user
    Same as the -u, --user option.

-e, --env VAR=VALUE
    Set the environment variable VAR to VALUE.

-g, --group group
    Start the daemon as in the group.

-k, --umask mode
    Set the umask of the daemon.

--notify fd:num | socket:ready
    Open file descriptor num as a pipe, and waits until the daemon writes a newline to it before exiting. Or waits for READY=1 in the datagram socket opened at $NOTIFY_SOCKET.

-m, --make-pidfile
    Saves the pid of the daemon in the file specified by the -p, --pidfile option. Only useful when used with daemons that run in the foreground and forced into the background with the -b, --background option.

-I, --ionice class[:data]
    Modifies the IO scheduling priority of the daemon. Class can be 0 for none, 1 for real time, 2 for best effort and 3 for idle. Data can be from 0 to 7 inclusive.

-N, --nicelevel level
    Modifies the scheduling priority of the daemon.

--oom-score-adj adj
    Modifies the OOM score adjustment of the daemon.

--scheduler policy
    Sets the scheduling policy of the daemon. Possible values are other, fifo and rr on POSIX systems and, additionally, batch and idle on Linux. If policy is an integer, it is passed directly to pthread_setschedparam(3).

--scheduler-priority priority
    Sets the priority parameter of the scheduling policy of the daemon. See sched(7) for details.

-0, --stdin file
    Redirect the standard input of the process to file when started with -background. The file Must be an absolute pathname, but relative to the path optionally given with -r, --chroot. The file can also be a named pipe. The file must exist, otherwise an error is emitted.

-1, --stdout logfile
    Redirect the standard output of the process to logfile when started with -background. The logfile Must be an absolute pathname, but relative to the path optionally given with -r, --chroot. The logfile can also be a named pipe.

-2, --stderr logfile
    Redirect the standard error of the process to logfile when started with -background. The logfile must be an absolute pathname, but relative to the path optionally given with -r, --chroot. The logfile can also be a named pipe.

-3, --stdout-logger cmd
    Run cmd as a child process redirecting the standard output to the standard input of cmd when started with -background. Cmd must be an absolute pathname, but relative to the path optionally given with -r, --chroot. This process must be prepared to accept input on stdin and be able to log it or send it to another location.

-4, --stderr-logger cmd
    Run cmd as a child process and Redirect the standard error of the process to the standard input of cmd when started with -background. Cmd must be an absolute pathname, but relative to the path optionally given with -r, --chroot. This process must be prepared to accept input on stdin and be able to log it or send it to another location.

--capabilities cap-list
    Start the daemon with the listed inheritable, ambient and bounding capabilities. The format is the same as in cap_iab(3).

--secbits sec-bits
    Set the security-bits for the program. The numeric value of the security-bits can be found in <sys/secbits.h> header file. The format is the same as in strtoul(3).

--no-new-privs
    Set the No New Privs flag for the program. See PR_SET_NO_NEW_PRIVS prctl(2).

-w, --wait milliseconds
    Wait milliseconds after starting and check that daemon is still running. Useful for daemons that check configuration after forking or stopping race conditions where the pidfile is written out after forking.

These options are only used for stopping daemons:

-R, --retry timeout | signal/timeout
    The retry specification can be either a timeout in seconds or multiple signal/timeout pairs (like SIGTERM/5). If this option is not given, the default is SIGTERM/5.

ENVIRONMENT
SSD_IONICELEVEL can also set the IO scheduling priority of the daemon, but the command line option takes precedence.

SSD_NICELEVEL can also set the scheduling priority of the daemon, but the command line option takes precedence.

SSD_OOM_SCORE_ADJ can also set the OOM score adjustment of the daemon, but the command line option takes precedence.

SSD_STARTWAIT As the -w, --wait -option -above. /etc/rc.conf start-stop-daemon waits for to check the daemon is still running.

NOTE
start-stop-daemon uses getopt(3) to parse its options, which allows it to accept the `--' option which will cause it to stop processing options at that point. Any subsequent arguments are passed as arguments to the daemon to start and used when finding a daemon to stop or signal.

SEE ALSO
chdir(2), chroot(2), getopt(3), nice(2), rc_find_pids(3)

BUGS
start-stop-daemon cannot stop an interpreted daemon that no longer exists without a pidfile.

HISTORY
start-stop-daemon first appeared in Debian.

This is a complete re-implementation with the process finding code in the OpenRC library (librc, -lrc) so other programs can make use of it.

AUTHORS
Roy Marples <roy@marples.name>