.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "start-stop-daemon 8" .TH start-stop-daemon 8 "2022-09-01" "1.20.12" "dpkg suite" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" start\-stop\-daemon \- start and stop system daemon programs .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBstart-stop-daemon\fR [\fIoption\fR...] \fIcommand\fR .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fBstart-stop-daemon\fR is used to control the creation and termination of system-level processes. Using one of the matching options, \fBstart-stop-daemon\fR can be configured to find existing instances of a running process. .PP \&\fBNote:\fR Unless \&\fB\-\-pid\fR or \&\fB\-\-pidfile\fR are specified, \&\fBstart-stop-daemon\fR behaves similar to \&\fBkillall\fR(1). \&\fBstart-stop-daemon\fR will scan the process table looking for any processes which match the process name, parent pid, uid, and/or gid (if specified). Any matching process will prevent \&\fB\-\-start\fR from starting the daemon. All matching processes will be sent the \s-1TERM\s0 signal (or the one specified via \fB\-\-signal\fR or \fB\-\-retry\fR) if \&\fB\-\-stop\fR is specified. For daemons which have long-lived children which need to live through a \&\fB\-\-stop\fR, you must specify a pidfile. .SH "COMMANDS" .IX Header "COMMANDS" .IP "\fB\-S\fR, \fB\-\-start\fR [\fB\-\-\fR] \fIarguments\fR" 4 .IX Item "-S, --start [--] arguments" Check for the existence of a specified process. If such a process exists, \&\fBstart-stop-daemon\fR does nothing, and exits with error status 1 (0 if \&\fB\-\-oknodo\fR is specified). If such a process does not exist, it starts an instance, using either the executable specified by \&\fB\-\-exec\fR or, if specified, by \&\fB\-\-startas\fR. Any arguments given after \&\fB\-\-\fR on the command line are passed unmodified to the program being started. .IP "\fB\-K\fR, \fB\-\-stop\fR" 4 .IX Item "-K, --stop" Checks for the existence of a specified process. If such a process exists, \&\fBstart-stop-daemon\fR sends it the signal specified by \&\fB\-\-signal\fR, and exits with error status 0. If such a process does not exist, \&\fBstart-stop-daemon\fR exits with error status 1 (0 if \&\fB\-\-oknodo\fR is specified). If \&\fB\-\-retry\fR is specified, then \&\fBstart-stop-daemon\fR will check that the process(es) have terminated. .IP "\fB\-T\fR, \fB\-\-status\fR" 4 .IX Item "-T, --status" Check for the existence of a specified process, and returns an exit status code, according to the \s-1LSB\s0 Init Script Actions (since version 1.16.1). .IP "\fB\-H\fR, \fB\-\-help\fR" 4 .IX Item "-H, --help" Show usage information and exit. .IP "\fB\-V\fR, \fB\-\-version\fR" 4 .IX Item "-V, --version" Show the program version and exit. .SH "OPTIONS" .IX Header "OPTIONS" .SS "Matching options" .IX Subsection "Matching options" .IP "\fB\-\-pid\fR \fIpid\fR" 4 .IX Item "--pid pid" Check for a process with the specified \fIpid\fR (since version 1.17.6). The \fIpid\fR must be a number greater than 0. .IP "\fB\-\-ppid\fR \fIppid\fR" 4 .IX Item "--ppid ppid" Check for a process with the specified parent pid \fIppid\fR (since version 1.17.7). The \fIppid\fR must be a number greater than 0. .IP "\fB\-p\fR, \fB\-\-pidfile\fR \fIpidfile\fR" 4 .IX Item "-p, --pidfile pidfile" Check whether a process has created the file \fIpidfile\fR. .Sp \&\fBNote:\fR Using this matching option alone might cause unintended processes to be acted on, if the old process terminated without being able to remove the \&\fIpidfile\fR. .Sp \&\fBWarning:\fR Using this match option with a world-writable pidfile or using it alone with a daemon that writes the pidfile as an unprivileged (non-root) user will be refused with an error (since version 1.19.3) as this is a security risk, because either any user can write to it, or if the daemon gets compromised, the contents of the pidfile cannot be trusted, and then a privileged runner (such as an init script executed as root) would end up acting on any system process. Using \fI/dev/null\fR is exempt from these checks. .IP "\fB\-x\fR, \fB\-\-exec\fR \fIexecutable\fR" 4 .IX Item "-x, --exec executable" Check for processes that are instances of this \fIexecutable\fR. The \&\fIexecutable\fR argument should be an absolute pathname. .Sp \&\fBNote:\fR This might not work as intended with interpreted scripts, as the executable will point to the interpreter. Take into account processes running from inside a chroot will also be matched, so other match restrictions might be needed. .IP "\fB\-n\fR, \fB\-\-name\fR \fIprocess-name\fR" 4 .IX Item "-n, --name process-name" Check for processes with the name \fIprocess-name\fR. The \fIprocess-name\fR is usually the process filename, but it could have been changed by the process itself. .Sp \&\fBNote:\fR On most systems this information is retrieved from the process comm name from the kernel, which tends to have a relatively short length limit (assuming more than 15 characters is non-portable). .IP "\fB\-u\fR, \fB\-\-user\fR \fIusername\fR|\fIuid\fR" 4 .IX Item "-u, --user username|uid" Check for processes owned by the user specified by \fIusername\fR or \&\fIuid\fR. .Sp \&\fBNote:\fR Using this matching option alone will cause all processes matching the user to be acted on. .SS "Generic options" .IX Subsection "Generic options" .IP "\fB\-g\fR, \fB\-\-group\fR \fIgroup\fR|\fIgid\fR" 4 .IX Item "-g, --group group|gid" Change to \fIgroup\fR or \fIgid\fR when starting the process. .IP "\fB\-s\fR, \fB\-\-signal\fR \fIsignal\fR" 4 .IX Item "-s, --signal signal" With \&\fB\-\-stop\fR, specifies the signal to send to processes being stopped (default \s-1TERM\s0). .IP "\fB\-R\fR, \fB\-\-retry\fR \fItimeout\fR|\fIschedule\fR" 4 .IX Item "-R, --retry timeout|schedule" With \&\fB\-\-stop\fR, specifies that \&\fBstart-stop-daemon\fR is to check whether the process(es) do finish. It will check repeatedly whether any matching processes are running, until none are. If the processes do not exit it will then take further action as determined by the schedule. .Sp If \&\fItimeout\fR is specified instead of \&\fIschedule\fR, then the schedule \&\fIsignal\fR\fB/\fR\fItimeout\fR\fB/KILL/\fR\fItimeout\fR is used, where \&\fIsignal\fR is the signal specified with \&\fB\-\-signal\fR. .Sp \&\fIschedule\fR is a list of at least two items separated by slashes (\fB/\fR); each item may be \&\fB\-\fR\fIsignal-number\fR or [\fB\-\fR]\fIsignal-name\fR, which means to send that signal, or \&\fItimeout\fR, which means to wait that many seconds for processes to exit, or \&\fBforever\fR, which means to repeat the rest of the schedule forever if necessary. .Sp If the end of the schedule is reached and \&\fBforever\fR is not specified, then \&\fBstart-stop-daemon\fR exits with error status 2. If a schedule is specified, then any signal specified with \&\fB\-\-signal\fR is ignored. .IP "\fB\-a\fR, \fB\-\-startas\fR \fIpathname\fR" 4 .IX Item "-a, --startas pathname" With \&\fB\-\-start\fR, start the process specified by \&\fIpathname\fR. If not specified, defaults to the argument given to \&\fB\-\-exec\fR. .IP "\fB\-t\fR, \fB\-\-test\fR" 4 .IX Item "-t, --test" Print actions that would be taken and set appropriate return value, but take no action. .IP "\fB\-o\fR, \fB\-\-oknodo\fR" 4 .IX Item "-o, --oknodo" Return exit status 0 instead of 1 if no actions are (would be) taken. .IP "\fB\-q\fR, \fB\-\-quiet\fR" 4 .IX Item "-q, --quiet" Do not print informational messages; only display error messages. .IP "\fB\-c\fR, \fB\-\-chuid\fR \fIusername\fR|\fIuid\fR[\fB:\fR\fIgroup\fR|\fIgid\fR]" 4 .IX Item "-c, --chuid username|uid[:group|gid]" Change to this username/uid before starting the process. You can also specify a group by appending a \&\fB:\fR, then the group or gid in the same way as you would for the \fBchown\fR(1) command (\fIuser\fR\fB:\fR\fIgroup\fR). If a user is specified without a group, the primary \s-1GID\s0 for that user is used. When using this option you must realize that the primary and supplemental groups are set as well, even if the \&\fB\-\-group\fR option is not specified. The \&\fB\-\-group\fR option is only for groups that the user isn't normally a member of (like adding per process group membership for generic users like \&\fBnobody\fR). .IP "\fB\-r\fR, \fB\-\-chroot\fR \fIroot\fR" 4 .IX Item "-r, --chroot root" Change directory and chroot to \&\fIroot\fR before starting the process. Please note that the pidfile is also written after the chroot. .IP "\fB\-d\fR, \fB\-\-chdir\fR \fIpath\fR" 4 .IX Item "-d, --chdir path" Change directory to \&\fIpath\fR before starting the process. This is done after the chroot if the \&\fB\-r\fR|\fB\-\-chroot\fR option is set. When not specified, \&\fBstart-stop-daemon\fR will change directory to the root directory before starting the process. .IP "\fB\-b\fR, \fB\-\-background\fR" 4 .IX Item "-b, --background" Typically used with programs that don't detach on their own. This option will force \&\fBstart-stop-daemon\fR to fork before starting the process, and force it into the background. .Sp \&\fBWarning: start-stop-daemon\fR cannot check the exit status if the process fails to execute for \&\fBany\fR reason. This is a last resort, and is only meant for programs that either make no sense forking on their own, or where it's not feasible to add the code for them to do this themselves. .IP "\fB\-\-notify\-await\fR" 4 .IX Item "--notify-await" Wait for the background process to send a readiness notification before considering the service started (since version 1.19.3). This implements parts of the systemd readiness protocol, as specified in the \fBsd_notify\fR(3) man page. The following variables are supported: .RS 4 .IP "\fBREADY=1\fR" 4 .IX Item "READY=1" The program is ready to give service, so we can exit safely. .IP "\fBEXTEND_TIMEOUT_USEC=\fR\fInumber\fR" 4 .IX Item "EXTEND_TIMEOUT_USEC=number" The program requests to extend the timeout by \fInumber\fR microseconds. This will reset the current timeout to the specified value. .IP "\fBERRNO=\fR\fInumber\fR" 4 .IX Item "ERRNO=number" The program is exiting with an error. Do the same and print the user-friendly string for the \fBerrno\fR value. .RE .RS 4 .RE .IP "\fB\-\-notify\-timeout\fR \fItimeout\fR" 4 .IX Item "--notify-timeout timeout" Set a timeout for the \fB\-\-notify\-await\fR option (since version 1.19.3). When the timeout is reached, \fBstart-stop-daemon\fR will exit with an error code, and no readiness notification will be awaited. The default is \fB60\fR seconds. .IP "\fB\-C\fR, \fB\-\-no\-close\fR" 4 .IX Item "-C, --no-close" Do not close any file descriptor when forcing the daemon into the background (since version 1.16.5). Used for debugging purposes to see the process output, or to redirect file descriptors to log the process output. Only relevant when using \fB\-\-background\fR. .IP "\fB\-O\fR, \fB\-\-output\fR \fIpathname\fR" 4 .IX Item "-O, --output pathname" Redirect \fBstdout\fR and \fBstderr\fR to \fIpathname\fR when forcing the daemon into the background (since version 1.20.6). Only relevant when using \fB\-\-background\fR. .IP "\fB\-N\fR, \fB\-\-nicelevel\fR \fIint\fR" 4 .IX Item "-N, --nicelevel int" This alters the priority of the process before starting it. .IP "\fB\-P\fR, \fB\-\-procsched\fR \fIpolicy\fR\fB:\fR\fIpriority\fR" 4 .IX Item "-P, --procsched policy:priority" This alters the process scheduler policy and priority of the process before starting it (since version 1.15.0). The priority can be optionally specified by appending a \fB:\fR followed by the value. The default \fIpriority\fR is 0. The currently supported policy values are \fBother\fR, \fBfifo\fR and \fBrr\fR. .IP "\fB\-I\fR, \fB\-\-iosched\fR \fIclass\fR\fB:\fR\fIpriority\fR" 4 .IX Item "-I, --iosched class:priority" This alters the \s-1IO\s0 scheduler class and priority of the process before starting it (since version 1.15.0). The priority can be optionally specified by appending a \fB:\fR followed by the value. The default \fIpriority\fR is 4, unless \fIclass\fR is \fBidle\fR, then \fIpriority\fR will always be 7. The currently supported values for \&\fIclass\fR are \fBidle\fR, \fBbest-effort\fR and \fBreal-time\fR. .IP "\fB\-k\fR, \fB\-\-umask\fR \fImask\fR" 4 .IX Item "-k, --umask mask" This sets the umask of the process before starting it (since version 1.13.22). .IP "\fB\-m\fR, \fB\-\-make\-pidfile\fR" 4 .IX Item "-m, --make-pidfile" Used when starting a program that does not create its own pid file. This option will make \&\fBstart-stop-daemon\fR create the file referenced with \&\fB\-\-pidfile\fR and place the pid into it just before executing the process. Note, the file will only be removed when stopping the program if \&\fB\-\-remove\-pidfile\fR is used. .Sp \&\fBNote:\fR This feature may not work in all cases. Most notably when the program being executed forks from its main process. Because of this, it is usually only useful when combined with the \&\fB\-\-background\fR option. .IP "\fB\-\-remove\-pidfile\fR" 4 .IX Item "--remove-pidfile" Used when stopping a program that does not remove its own pid file (since version 1.17.19). This option will make \&\fBstart-stop-daemon\fR remove the file referenced with \&\fB\-\-pidfile\fR after terminating the process. .IP "\fB\-v\fR, \fB\-\-verbose\fR" 4 .IX Item "-v, --verbose" Print verbose informational messages. .SH "EXIT STATUS" .IX Header "EXIT STATUS" .IP "\fB0\fR" 4 .IX Item "0" The requested action was performed. If \&\fB\-\-oknodo\fR was specified, it's also possible that nothing had to be done. This can happen when \&\fB\-\-start\fR was specified and a matching process was already running, or when \&\fB\-\-stop\fR was specified and there were no matching processes. .IP "\fB1\fR" 4 .IX Item "1" If \&\fB\-\-oknodo\fR was not specified and nothing was done. .IP "\fB2\fR" 4 .IX Item "2" If \&\fB\-\-stop\fR and \&\fB\-\-retry\fR were specified, but the end of the schedule was reached and the processes were still running. .IP "\fB3\fR" 4 .IX Item "3" Any other error. .PP When using the \fB\-\-status\fR command, the following status codes are returned: .IP "\fB0\fR" 4 .IX Item "0" Program is running. .IP "\fB1\fR" 4 .IX Item "1" Program is not running and the pid file exists. .IP "\fB3\fR" 4 .IX Item "3" Program is not running. .IP "\fB4\fR" 4 .IX Item "4" Unable to determine program status. .SH "EXAMPLE" .IX Header "EXAMPLE" Start the \fBfood\fR daemon, unless one is already running (a process named food, running as user food, with pid in food.pid): .Sp .Vb 3 \& start\-stop\-daemon \-\-start \-\-oknodo \-\-user food \-\-name food \e \& \-\-pidfile /run/food.pid \-\-startas /usr/sbin/food \e \& \-\-chuid food \-\- \-\-daemon .Ve .PP Send \fB\s-1SIGTERM\s0\fR to \fBfood\fR and wait up to 5 seconds for it to stop: .Sp .Vb 2 \& start\-stop\-daemon \-\-stop \-\-oknodo \-\-user food \-\-name food \e \& \-\-pidfile /run/food.pid \-\-retry 5 .Ve .PP Demonstration of a custom schedule for stopping \fBfood\fR: .Sp .Vb 2 \& start\-stop\-daemon \-\-stop \-\-oknodo \-\-user food \-\-name food \e \& \-\-pidfile /run/food.pid \-\-retry=TERM/30/KILL/5 .Ve