1 # dpkg manual page - start-stop-daemon(8)
3 # Copyright © 1999 Klee Dienes <klee@mit.edu>
4 # Copyright © 1999 Ben Collins <bcollins@debian.org>
5 # Copyright © 2000-2001 Wichert Akkerman <wakkerma@debian.org>
6 # Copyright © 2002-2003 Adam Heath <doogie@debian.org>
7 # Copyright © 2004 Scott James Remnant <keybuk@debian.org>
8 # Copyright © 2008-2016, 2018 Guillem Jover <guillem@debian.org>
10 # This is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program. If not, see <https://www.gnu.org/licenses/>.
27 start-stop-daemon - start and stop system daemon programs
32 [I<option>...] I<command>
37 is used to control the creation and termination of system-level processes.
38 Using one of the matching options, B<start-stop-daemon>
39 can be configured to find existing instances of a running process.
50 will scan the process table looking for any processes which
51 match the process name, parent pid, uid, and/or gid (if specified). Any
52 matching process will prevent
54 from starting the daemon. All matching processes will be sent the TERM
55 signal (or the one specified via B<--signal> or B<--retry>) if
57 is specified. For daemons which have long-lived children
58 which need to live through a
60 you must specify a pidfile.
66 =item B<-S>, B<--start> [B<-->] I<arguments>
68 Check for the existence of a specified process.
69 If such a process exists,
71 does nothing, and exits with error status 1 (0 if
74 If such a process does not exist, it starts an
75 instance, using either the executable specified by
79 Any arguments given after
81 on the command line are passed unmodified to the program being
84 =item B<-K>, B<--stop>
86 Checks for the existence of a specified process.
87 If such a process exists,
89 sends it the signal specified by
91 and exits with error status 0.
92 If such a process does not exist,
94 exits with error status 1
101 will check that the process(es) have terminated.
103 =item B<-T>, B<--status>
105 Check for the existence of a specified process, and returns an exit status
106 code, according to the LSB Init Script Actions (since version 1.16.1).
108 =item B<-H>, B<--help>
110 Show usage information and exit.
112 =item B<-V>, B<--version>
114 Show the program version and exit.
120 =head2 Matching options
124 =item B<--pid> I<pid>
126 Check for a process with the specified I<pid> (since version 1.17.6).
127 The I<pid> must be a number greater than 0.
129 =item B<--ppid> I<ppid>
131 Check for a process with the specified parent pid I<ppid>
132 (since version 1.17.7).
133 The I<ppid> must be a number greater than 0.
135 =item B<-p>, B<--pidfile> I<pidfile>
137 Check whether a process has created the file I<pidfile>.
139 B<Note>: Using this matching option alone might cause unintended processes to
140 be acted on, if the old process terminated without being able to remove the
143 B<Warning>: Using this match option with a world-writable pidfile or using
144 it alone with a daemon that writes the pidfile as an unprivileged (non-root)
145 user will be refused with an error (since version 1.19.3) as this is a
146 security risk, because either any user can write to it, or if the daemon
147 gets compromised, the contents of the pidfile cannot be trusted, and then
148 a privileged runner (such as an init script executed as root) would end up
149 acting on any system process.
150 Using I</dev/null> is exempt from these checks.
152 =item B<-x>, B<--exec> I<executable>
154 Check for processes that are instances of this I<executable>. The
155 I<executable> argument should be an absolute pathname.
158 not work as intended with interpreted scripts, as the executable will point
159 to the interpreter. Take into account processes running from inside a chroot
160 will also be matched, so other match restrictions might be needed.
162 =item B<-n>, B<--name> I<process-name>
164 Check for processes with the name I<process-name>. The I<process-name>
165 is usually the process filename, but it could have been changed by the
168 B<Note>: On most systems this information is retrieved from
169 the process comm name from the kernel, which tends to have a relatively
170 short length limit (assuming more than 15 characters is non-portable).
172 =item B<-u>, B<--user> I<username>|I<uid>
174 Check for processes owned by the user specified by I<username> or
177 B<Note>: Using this matching option alone will cause all processes
178 matching the user to be acted on.
182 =head2 Generic options
186 =item B<-g>, B<--group> I<group>|I<gid>
188 Change to I<group> or I<gid> when starting the process.
190 =item B<-s>, B<--signal> I<signal>
194 specifies the signal to send to processes being stopped (default TERM).
196 =item B<-R>, B<--retry> I<timeout>|I<schedule>
202 is to check whether the process(es)
203 do finish. It will check repeatedly whether any matching processes
204 are running, until none are. If the processes do not exit it will
205 then take further action as determined by the schedule.
209 is specified instead of
212 I<signal>B</>I<timeout>B</KILL/>I<timeout>
215 is the signal specified with
219 is a list of at least two items separated by slashes
223 or [B<->]I<signal-name>,
224 which means to send that signal,
227 which means to wait that many seconds for processes to
231 which means to repeat the rest of the schedule forever if
234 If the end of the schedule is reached and
236 is not specified, then
238 exits with error status 2.
239 If a schedule is specified, then any signal specified
244 =item B<-a>, B<--startas> I<pathname>
248 start the process specified by
250 If not specified, defaults to the argument given to
253 =item B<-t>, B<--test>
255 Print actions that would be taken and set appropriate return value,
258 =item B<-o>, B<--oknodo>
260 Return exit status 0 instead of 1 if no actions are (would be) taken.
262 =item B<-q>, B<--quiet>
264 Do not print informational messages; only display error messages.
266 =item B<-c>, B<--chuid> I<username>|I<uid>[B<:>I<group>|I<gid>]
268 Change to this username/uid before starting the process. You can also
269 specify a group by appending a
271 then the group or gid in the same way
272 as you would for the B<chown>(1) command (I<user>B<:>I<group>).
273 If a user is specified without a group, the primary GID for that user is used.
274 When using this option
275 you must realize that the primary and supplemental groups are set as well,
278 option is not specified. The
281 groups that the user isn't normally a member of (like adding per process
282 group membership for generic users like
285 =item B<-r>, B<--chroot> I<root>
287 Change directory and chroot to
289 before starting the process. Please note that the pidfile is also written
292 =item B<-d>, B<--chdir> I<path>
296 before starting the process. This is done after the chroot if the
297 B<-r>|B<--chroot> option is set. When not specified,
299 will change directory to the root directory before starting the process.
301 =item B<-b>, B<--background>
303 Typically used with programs that don't detach on their own. This option
306 to fork before starting the process, and force it into the background.
308 B<Warning>: B<start-stop-daemon>
309 cannot check the exit status if the process fails to execute for
311 reason. This is a last resort, and is only meant for programs that either
312 make no sense forking on their own, or where it's not feasible to add the
313 code for them to do this themselves.
315 =item B<--notify-await>
317 Wait for the background process to send a readiness notification before
318 considering the service started (since version 1.19.3).
319 This implements parts of the systemd readiness protocol, as specified
320 in the B<sd_notify>(3) manual page.
321 The following variables are supported:
327 The program is ready to give service, so we can exit safely.
329 =item B<EXTEND_TIMEOUT_USEC=>I<number>
331 The program requests to extend the timeout by I<number> microseconds.
332 This will reset the current timeout to the specified value.
334 =item B<ERRNO=>I<number>
336 The program is exiting with an error.
337 Do the same and print the user-friendly string for the B<errno> value.
341 =item B<--notify-timeout> I<timeout>
343 Set a timeout for the B<--notify-await> option (since version 1.19.3).
344 When the timeout is reached, B<start-stop-daemon> will exit with an
345 error code, and no readiness notification will be awaited.
346 The default is B<60> seconds.
348 =item B<-C>, B<--no-close>
350 Do not close any file descriptor when forcing the daemon into the background
351 (since version 1.16.5).
352 Used for debugging purposes to see the process output, or to redirect file
353 descriptors to log the process output.
354 Only relevant when using B<--background>.
356 =item B<-O>, B<--output> I<pathname>
358 Redirect B<stdout> and B<stderr> to I<pathname> when forcing the daemon into
359 the background (since version 1.20.6).
360 Only relevant when using B<--background>.
362 =item B<-N>, B<--nicelevel> I<int>
364 This alters the priority of the process before starting it.
366 =item B<-P>, B<--procsched> I<policy>B<:>I<priority>
368 This alters the process scheduler policy and priority of the process before
369 starting it (since version 1.15.0).
370 The priority can be optionally specified by appending a B<:>
371 followed by the value. The default I<priority> is 0. The currently
372 supported policy values are B<other>, B<fifo> and B<rr>.
374 This option might do nothing on some systems,
375 where POSIX process scheduling is not supported.
377 =item B<-I>, B<--iosched> I<class>B<:>I<priority>
379 This alters the IO scheduler class and priority of the process before starting
380 it (since version 1.15.0).
381 The priority can be optionally specified by appending a B<:> followed
382 by the value. The default I<priority> is 4, unless I<class> is B<idle>,
383 then I<priority> will always be 7. The currently supported values for
384 I<class> are B<idle>, B<best-effort> and B<real-time>.
386 This option might do nothing on some systems,
387 where Linux IO scheduling is not supported.
389 =item B<-k>, B<--umask> I<mask>
391 This sets the umask of the process before starting it (since version 1.13.22).
393 =item B<-m>, B<--make-pidfile>
395 Used when starting a program that does not create its own pid file. This
398 create the file referenced with
400 and place the pid into it just before executing the process. Note, the
401 file will only be removed when stopping the program if
402 B<--remove-pidfile> is used.
405 This feature may not work in all cases. Most notably when the program
406 being executed forks from its main process. Because of this, it is usually
407 only useful when combined with the
411 =item B<--remove-pidfile>
413 Used when stopping a program that does not remove its own pid file
414 (since version 1.17.19).
415 This option will make
417 remove the file referenced with
419 after terminating the process.
421 =item B<-v>, B<--verbose>
423 Print verbose informational messages.
433 The requested action was performed. If
435 was specified, it's also possible that nothing had to be done.
438 was specified and a matching process was already running, or when
440 was specified and there were no matching processes.
446 was not specified and nothing was done.
454 were specified, but the end of the schedule was reached and the processes were
463 When using the B<--status> command, the following status codes are
474 Program is not running and the pid file exists.
478 Program is not running.
482 Unable to determine program status.
488 Start the B<food> daemon, unless one is already running (a process named
489 food, running as user food, with pid in food.pid):
493 start-stop-daemon --start --oknodo --user food --name food \
494 --pidfile %RUNSTATEDIR%/food.pid --startas /usr/sbin/food \
495 --chuid food -- --daemon
499 Send B<SIGTERM> to B<food> and wait up to 5 seconds for it to stop:
503 start-stop-daemon --stop --oknodo --user food --name food \
504 --pidfile %RUNSTATEDIR%/food.pid --retry 5
508 Demonstration of a custom schedule for stopping B<food>:
512 start-stop-daemon --stop --oknodo --user food --name food \
513 --pidfile %RUNSTATEDIR%/food.pid --retry=TERM/30/KILL/5