START-STOP-DAEMON(8) System Manager's Manual START-STOP-DAEMON(8)NAMEstart-stop-daemon — ensures that daemons start and stop
SYNOPSISstart-stop-daemon-S, --start daemon [--] [arguments]
start-stop-daemon-K, --stop daemon
start-stop-daemon-s, --signal signal daemon
DESCRIPTIONstart-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 dae‐
mon 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 ser‐
vice 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 pid(s) 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.
-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.
-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, --nice level
Modifies the scheduling priority of the daemon.
-1, --stdout logfile
Redirect the standard output of the process to logfile when
started with -background. Must be an absolute pathname, but rel‐
ative to the path optionally given with -r, --chroot. The log‐
file can also be a named pipe.
-w, --wait milliseconds
Wait milliseconds after starting and check that daemon is still
running. Useful for daemons that check configuration after fork‐
ing or stopping race conditions where the pidfile is written out
after forking.
-2, --stderr logfile
The same thing as -1, --stdout but with the standard error out‐
put.
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).
ENVIRONMENT
SSD_NICELEVEL can also set the scheduling priority 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.
NOTEstart-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 dae‐
mon to start and used when finding a daemon to stop or signal.
SEE ALSOchdir(2), chroot(2), getopt(3), nice(2), rc_find_pids(3)BUGSstart-stop-daemon cannot stop an interpreted daemon that no longer exists
without a pidfile.
HISTORYstart-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>
OpenRC December 14, 2009 OpenRC