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).
53 matching process will prevent
55 from starting the daemon.
56 All matching processes will be sent the TERM
57 signal (or the one specified via B<--signal> or B<--retry>) if
60 For daemons which have long-lived children
61 which need to live through a
63 you must specify a pidfile.
69 =item B<-S>, B<--start> [B<-->] I<arguments>
71 Check for the existence of a specified process.
72 If such a process exists,
74 does nothing, and exits with error status 1 (0 if
77 If such a process does not exist, it starts an
78 instance, using either the executable specified by
82 Any arguments given after
84 on the command line are passed unmodified to the program being
87 =item B<-K>, B<--stop>
89 Checks for the existence of a specified process.
90 If such a process exists,
92 sends it the signal specified by
94 and exits with error status 0.
95 If such a process does not exist,
97 exits with error status 1
105 will check that the process(es) have terminated.
107 =item B<-T>, B<--status>
109 Check for the existence of a specified process, and returns an exit status
110 code, according to the LSB Init Script Actions (since version 1.16.1).
112 =item B<-H>, B<--help>
114 Show usage information and exit.
116 =item B<-V>, B<--version>
118 Show the program version and exit.
124 =head2 Matching options
128 =item B<--pid> I<pid>
130 Check for a process with the specified I<pid> (since version 1.17.6).
131 The I<pid> must be a number greater than 0.
133 =item B<--ppid> I<ppid>
135 Check for a process with the specified parent pid I<ppid>
136 (since version 1.17.7).
137 The I<ppid> must be a number greater than 0.
139 =item B<-p>, B<--pidfile> I<pidfile>
141 Check whether a process has created the file I<pidfile>.
143 B<Note>: Using this matching option alone might cause unintended processes to
144 be acted on, if the old process terminated without being able to remove the
147 B<Warning>: Using this match option with a world-writable pidfile or using
148 it alone with a daemon that writes the pidfile as an unprivileged (non-root)
149 user will be refused with an error (since version 1.19.3) as this is a
150 security risk, because either any user can write to it, or if the daemon
151 gets compromised, the contents of the pidfile cannot be trusted, and then
152 a privileged runner (such as an init script executed as root) would end up
153 acting on any system process.
154 Using I</dev/null> is exempt from these checks.
156 =item B<-x>, B<--exec> I<executable>
158 Check for processes that are instances of this I<executable>.
160 I<executable> argument should be an absolute pathname.
163 not work as intended with interpreted scripts, as the executable will point
165 Take into account processes running from inside a chroot
166 will also be matched, so other match restrictions might be needed.
168 =item B<-n>, B<--name> I<process-name>
170 Check for processes with the name I<process-name>.
172 is usually the process filename, but it could have been changed by the
175 B<Note>: On most systems this information is retrieved from
176 the process comm name from the kernel, which tends to have a relatively
177 short length limit (assuming more than 15 characters is non-portable).
179 =item B<-u>, B<--user> I<username>|I<uid>
181 Check for processes owned by the user specified by I<username> or
184 B<Note>: Using this matching option alone will cause all processes
185 matching the user to be acted on.
189 =head2 Generic options
193 =item B<-g>, B<--group> I<group>|I<gid>
195 Change to I<group> or I<gid> when starting the process.
197 =item B<-s>, B<--signal> I<signal>
201 specifies the signal to send to processes being stopped (default TERM).
203 =item B<-R>, B<--retry> I<timeout>|I<schedule>
209 is to check whether the process(es)
211 It will check repeatedly whether any matching processes are running,
213 If the processes do not exit it will
214 then take further action as determined by the schedule.
218 is specified instead of
221 I<signal>B</>I<timeout>B</KILL/>I<timeout>
224 is the signal specified with
228 is a list of at least two items separated by slashes
232 or [B<->]I<signal-name>,
233 which means to send that signal,
236 which means to wait that many seconds for processes to
240 which means to repeat the rest of the schedule forever if
243 If the end of the schedule is reached and
245 is not specified, then
247 exits with error status 2.
248 If a schedule is specified, then any signal specified
253 =item B<-a>, B<--startas> I<pathname>
257 start the process specified by
259 If not specified, defaults to the argument given to
262 =item B<-t>, B<--test>
264 Print actions that would be taken and set appropriate return value,
267 =item B<-o>, B<--oknodo>
269 Return exit status 0 instead of 1 if no actions are (would be) taken.
271 =item B<-q>, B<--quiet>
273 Do not print informational messages; only display error messages.
275 =item B<-c>, B<--chuid> I<username>|I<uid>[B<:>I<group>|I<gid>]
277 Change to this username/uid before starting the process.
279 specify a group by appending a
281 then the group or gid in the same way
282 as you would for the L<chown(1)> command (I<user>B<:>I<group>).
283 If a user is specified without a group, the primary GID for that user is used.
284 When using this option
285 you must realize that the primary and supplemental groups are set as well,
288 option is not specified.
292 groups that the user isn't normally a member of (like adding per process
293 group membership for generic users like
296 =item B<-r>, B<--chroot> I<root>
298 Change directory and chroot to
300 before starting the process.
301 Please note that the pidfile is also written
304 =item B<-d>, B<--chdir> I<path>
308 before starting the process.
309 This is done after the chroot if the B<-r>|B<--chroot> option is set.
312 will change directory to the root directory before starting the process.
314 =item B<-b>, B<--background>
316 Typically used with programs that don't detach on their own.
320 to fork before starting the process, and force it into the background.
322 B<Warning>: B<start-stop-daemon>
323 cannot check the exit status if the process fails to execute for
326 This is a last resort, and is only meant for programs that either
327 make no sense forking on their own, or where it's not feasible to add the
328 code for them to do this themselves.
330 =item B<--notify-await>
332 Wait for the background process to send a readiness notification before
333 considering the service started (since version 1.19.3).
334 This implements parts of the systemd readiness protocol, as specified
335 in the L<sd_notify(3)> manual page.
336 The following variables are supported:
342 The program is ready to give service, so we can exit safely.
344 =item B<EXTEND_TIMEOUT_USEC=>I<number>
346 The program requests to extend the timeout by I<number> microseconds.
347 This will reset the current timeout to the specified value.
349 =item B<ERRNO=>I<number>
351 The program is exiting with an error.
352 Do the same and print the user-friendly string for the B<errno> value.
356 =item B<--notify-timeout> I<timeout>
358 Set a timeout for the B<--notify-await> option (since version 1.19.3).
359 When the timeout is reached, B<start-stop-daemon> will exit with an
360 error code, and no readiness notification will be awaited.
361 The default is B<60> seconds.
363 =item B<-C>, B<--no-close>
365 Do not close any file descriptor when forcing the daemon into the background
366 (since version 1.16.5).
367 Used for debugging purposes to see the process output, or to redirect file
368 descriptors to log the process output.
369 Only relevant when using B<--background>.
371 =item B<-O>, B<--output> I<pathname>
373 Redirect B<stdout> and B<stderr> to I<pathname> when forcing the daemon into
374 the background (since version 1.20.6).
375 Only relevant when using B<--background>.
377 =item B<-N>, B<--nicelevel> I<int>
379 This alters the priority of the process before starting it.
381 =item B<-P>, B<--procsched> I<policy>B<:>I<priority>
383 This alters the process scheduler policy and priority of the process before
384 starting it (since version 1.15.0).
385 The priority can be optionally specified by appending a B<:>
386 followed by the value.
387 The default I<priority> is 0.
389 supported policy values are B<other>, B<fifo> and B<rr>.
391 This option might do nothing on some systems,
392 where POSIX process scheduling is not supported.
394 =item B<-I>, B<--iosched> I<class>B<:>I<priority>
396 This alters the IO scheduler class and priority of the process before starting
397 it (since version 1.15.0).
398 The priority can be optionally specified by appending a B<:> followed
400 The default I<priority> is 4, unless I<class> is B<idle>,
401 then I<priority> will always be 7.
402 The currently supported values for
403 I<class> are B<idle>, B<best-effort> and B<real-time>.
405 This option might do nothing on some systems,
406 where Linux IO scheduling is not supported.
408 =item B<-k>, B<--umask> I<mask>
410 This sets the umask of the process before starting it (since version 1.13.22).
412 =item B<-m>, B<--make-pidfile>
414 Used when starting a program that does not create its own pid file.
418 create the file referenced with
420 and place the pid into it just before executing the process.
422 file will only be removed when stopping the program if
423 B<--remove-pidfile> is used.
426 This feature may not work in all cases.
427 Most notably when the program being executed forks from its main process.
428 Because of this, it is usually
429 only useful when combined with the
433 =item B<--remove-pidfile>
435 Used when stopping a program that does not remove its own pid file
436 (since version 1.17.19).
437 This option will make
439 remove the file referenced with
441 after terminating the process.
443 =item B<-v>, B<--verbose>
445 Print verbose informational messages.
455 The requested action was performed.
458 was specified, it's also possible that nothing had to be done.
461 was specified and a matching process was already running, or when
463 was specified and there were no matching processes.
469 was not specified and nothing was done.
477 were specified, but the end of the schedule was reached and the processes were
486 When using the B<--status> command, the following status codes are
497 Program is not running and the pid file exists.
501 Program is not running.
505 Unable to determine program status.
511 Start the B<food> daemon, unless one is already running (a process named
512 food, running as user food, with pid in food.pid):
516 start-stop-daemon --start --oknodo --user food --name food \
517 --pidfile %RUNSTATEDIR%/food.pid --startas /usr/sbin/food \
518 --chuid food -- --daemon
522 Send B<SIGTERM> to B<food> and wait up to 5 seconds for it to stop:
526 start-stop-daemon --stop --oknodo --user food --name food \
527 --pidfile %RUNSTATEDIR%/food.pid --retry 5
531 Demonstration of a custom schedule for stopping B<food>:
535 start-stop-daemon --stop --oknodo --user food --name food \
536 --pidfile %RUNSTATEDIR%/food.pid --retry=TERM/30/KILL/5