START-STOP-DAEMON(8) System Manager's Manual (smm) START-STOP-DAEMON(8)

# [NAME](#NAME)

`start-stop-daemon` — ensures that daemons start and stop

# [SYNOPSIS](#SYNOPSIS)

`start-stop-daemon` `-S`, `--start` `daemon` \[`--`] \[`arguments`]

`start-stop-daemon` `-K`, `--stop` `daemon`

`start-stop-daemon` `-s`, `--signal` `signal` `daemon`

# [DESCRIPTION](#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`](#x), `--exec` `daemon`

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

[`-p`](#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`](#n), `--name` `name`

Match the process `name` instead of a pidfile or executable.

[`-i`](#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`](#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`](#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`](#v), `--verbose`

Print the action(s) that are taken just before doing them.

[`-q`](#q), `--quiet`

Run quietly (repeat to suppress errors).

[`-P`](#P), `--progress`

Echo a . to the console for each second elapsed whilst waiting.

These options are only used for starting daemons:

[`-a`](#a), `--startas` `name`

Change the process name of the daemon to `name`. This just changes the first argument passed to the daemon.

[`-b`](#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`](#d), `--chdir` `path`

chdir to this directory before starting the daemon.

[`-r`](#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`](#c), `--chuid` `user`

Same as the `-u`, `--user` option.

[`-e`](#e), `--env` `VAR=VALUE`

Set the environment variable VAR to VALUE.

[`-g`](#g), `--group` `group`

Start the daemon as in the group.

[`-k`](#k), `--umask` `mode`

Set the umask of the daemon.

[`--notify`](#notify) fd:`num` | [socket:ready](#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`](#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`](#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`](#N), `--nicelevel` `level`

Modifies the scheduling priority of the daemon.

[`--oom-score-adj`](#oom-score-adj) `adj`

Modifies the OOM score adjustment of the daemon.

[`--scheduler`](#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)](/man/os/openrc/pthread_setschedparam.3).

[`--scheduler-priority`](#scheduler-priority) `priority`

Sets the priority parameter of the scheduling policy of the daemon. See [sched(7)](/man/os/openrc/sched.7) for details.

[`-0`](#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`](#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`](#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`](#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`](#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`](#capabilities) `cap-list`

Start the daemon with the listed inheritable, ambient and bounding capabilities. The format is the same as in [cap\_iab(3)](/man/os/openrc/cap_iab.3).

[`--secbits`](#secbits) `sec-bits`

Set the security-bits for the program. The numeric value of the security-bits can be found in &lt;sys/secbits.h&gt; header file. The format is the same as in [strtoul(3)](/man/os/openrc/strtoul.3).

[`--no-new-privs`](#no-new-privs)

Set the No New Privs flag for the program. See PR\_SET\_NO\_NEW\_PRIVS [prctl(2)](/man/os/openrc/prctl.2).

[`-w`](#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`](#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](#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](#NOTE)

`start-stop-daemon` uses [getopt(3)](/man/os/openrc/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](#SEE_ALSO)

[chdir(2)](/man/os/openrc/chdir.2), [chroot(2)](/man/os/openrc/chroot.2), [getopt(3)](/man/os/openrc/getopt.3), [nice(2)](/man/os/openrc/nice.2), [rc\_find\_pids(3)](/man/os/openrc/rc_find_pids.3)

# [BUGS](#BUGS)

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

# [HISTORY](#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](#AUTHORS)

Roy Marples &lt;roy@marples.name&gt;

December 14, 2009 OpenRC

---

Document: start-stop-daemon(8) from openrc 0.64.1-r2 (Chainguard OS)
Source: https://github.com/OpenRC/openrc
