START-STOP-DAEMON¶
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 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 then start-stop-daemon matches the process 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 relative to the path optionally given with -r , -chroot. The logfile 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 forking 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 output.
These options are only used for stopping daemons:
-R , -retry timeout | signal / timeout
You can either specify a timeout in seconds or a multiple signal/timeout pairs as a stopping schedule. If not specified then a default value of SIGTERM/5 is assumed.
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.
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>