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-2015 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/>.
23 .TH start\-stop\-daemon 8 "%RELEASE_DATE%" "%VERSION%" "dpkg suite"
26 start\-stop\-daemon \- start and stop system daemon programs
29 .B start\-stop\-daemon
30 .RI [ option "...] " command
33 .B start\-stop\-daemon
34 is used to control the creation and termination of system-level processes.
35 Using one of the matching options, \fBstart\-stop\-daemon\fP
36 can be configured to find existing instances of a running process.
43 .B start\-stop\-daemon
46 .B start\-stop\-daemon
47 will scan the process table looking for any processes which
48 match the process name, parent pid, uid, and/or gid (if specified). Any
49 matching process will prevent
51 from starting the daemon. All matching processes will be sent the TERM
52 signal (or the one specified via \fB\-\-signal\fP or \fB\-\-retry\fP) if
54 is specified. For daemons which have long-lived children
55 which need to live through a
57 you must specify a pidfile.
61 .BR \-S ", " \-\-start " [" \-\- "] \fIarguments\fP"
62 Check for the existence of a specified process.
63 If such a process exists,
64 .B start\-stop\-daemon
65 does nothing, and exits with error status 1 (0 if
68 If such a process does not exist, it starts an
69 instance, using either the executable specified by
73 Any arguments given after
75 on the command line are passed unmodified to the program being
79 Checks for the existence of a specified process.
80 If such a process exists,
81 .B start\-stop\-daemon
82 sends it the signal specified by
84 and exits with error status 0.
85 If such a process does not exist,
86 .B start\-stop\-daemon
87 exits with error status 1
93 .B start\-stop\-daemon
94 will check that the process(es) have terminated.
96 .BR \-T ", " \-\-status
97 Check for the existence of a specified process, and returns an exit status
98 code, according to the LSB Init Script Actions (since version 1.16.1).
100 .BR \-H ", " \-\-help
101 Show usage information and exit.
103 .BR \-V ", " \-\-version
104 Show the program version and exit.
109 .BR \-\-pid " \fIpid\fP"
110 Check for a process with the specified \fIpid\fP (since version 1.17.6).
111 The \fIpid\fP must be a number greater than 0.
113 .BR \-\-ppid " \fIppid\fP"
114 Check for a process with the specified parent pid \fIppid\fP
115 (since version 1.17.7).
116 The \fIppid\fP must be a number greater than 0.
118 .BR \-p ", " \-\-pidfile " \fIpid-file\fP"
119 Check whether a process has created the file \fIpid-file\fP. Note: using this
120 matching option alone might cause unintended processes to be acted on, if the
121 old process terminated without being able to remove the \fIpid-file\fP.
123 .BR \-x ", " \-\-exec " \fIexecutable\fP"
124 Check for processes that are instances of this \fIexecutable\fP. The
125 \fIexecutable\fP argument should be an absolute pathname. Note: this might
126 not work as intended with interpreted scripts, as the executable will point
127 to the interpreter. Take into account processes running from inside a chroot
128 will also be matched, so other match restrictions might be needed.
130 .BR \-n ", " \-\-name " \fIprocess-name\fP"
131 Check for processes with the name \fIprocess-name\fP. The \fIprocess-name\fP
132 is usually the process filename, but it could have been changed by the
133 process itself. Note: on most systems this information is retrieved from
134 the process comm name from the kernel, which tends to have a relatively
135 short length limit (assuming more than 15 characters is non-portable).
137 .BR \-u ", " \-\-user " \fIusername\fP|\fIuid\fP
138 Check for processes owned by the user specified by \fIusername\fP or
139 \fIuid\fP. Note: using this matching option alone will cause all processes
140 matching the user to be acted on.
144 .BR \-g ", " \-\-group " \fIgroup\fP|\fIgid\fP"
145 Change to \fIgroup\fP or \fIgid\fP when starting the process.
147 .BR \-s ", " \-\-signal " \fIsignal\fP"
150 specifies the signal to send to processes being stopped (default TERM).
152 .BR \-R ", " \-\-retry " \fItimeout\fP|\fIschedule\fP"
156 .B start\-stop\-daemon
157 is to check whether the process(es)
158 do finish. It will check repeatedly whether any matching processes
159 are running, until none are. If the processes do not exit it will
160 then take further action as determined by the schedule.
164 is specified instead of
167 .IB signal / timeout /KILL/ timeout
170 is the signal specified with
174 is a list of at least two items separated by slashes
178 or [\fB\-\fP]\fIsignal-name\fP,
179 which means to send that signal,
182 which means to wait that many seconds for processes to
186 which means to repeat the rest of the schedule forever if
189 If the end of the schedule is reached and
191 is not specified, then
192 .B start\-stop\-daemon
193 exits with error status 2.
194 If a schedule is specified, then any signal specified
199 .BR \-a ", " \-\-startas " \fIpathname\fP"
202 start the process specified by
204 If not specified, defaults to the argument given to
207 .BR \-t ", " \-\-test
208 Print actions that would be taken and set appropriate return value,
211 .BR \-o ", " \-\-oknodo
212 Return exit status 0 instead of 1 if no actions are (would be) taken.
214 .BR \-q ", " \-\-quiet
215 Do not print informational messages; only display error messages.
217 .BR \-c ", " \-\-chuid " \fIusername\fR|\fIuid\fP[\fB:\fP\fIgroup\fR|\fIgid\fP]"
218 Change to this username/uid before starting the process. You can also
219 specify a group by appending a
221 then the group or gid in the same way
222 as you would for the \fBchown\fP(1) command (\fIuser\fP\fB:\fP\fIgroup\fP).
223 If a user is specified without a group, the primary GID for that user is used.
224 When using this option
225 you must realize that the primary and supplemental groups are set as well,
228 option is not specified. The
231 groups that the user isn't normally a member of (like adding per process
232 group membership for generic users like
235 .BR \-r ", " \-\-chroot " \fIroot\fP"
238 before starting the process. Please note that the pidfile is also written
241 .BR \-d ", " \-\-chdir " \fIpath\fP"
244 before starting the process. This is done after the chroot if the
245 \fB\-r\fP|\fB\-\-chroot\fP option is set. When not specified,
246 .B start\-stop\-daemon
247 will chdir to the root directory before starting the process.
249 .BR \-b ", " \-\-background
250 Typically used with programs that don't detach on their own. This option
252 .B start\-stop\-daemon
253 to fork before starting the process, and force it into the background.
254 .B Warning: start\-stop\-daemon
255 cannot check the exit status if the process fails to execute for
257 reason. This is a last resort, and is only meant for programs that either
258 make no sense forking on their own, or where it's not feasible to add the
259 code for them to do this themselves.
261 .BR \-C ", " \-\-no\-close
262 Do not close any file descriptor when forcing the daemon into the background
263 (since version 1.16.5).
264 Used for debugging purposes to see the process output, or to redirect file
265 descriptors to log the process output.
266 Only relevant when using \fB\-\-background\fP.
268 .BR \-N ", " \-\-nicelevel " \fIint\fP"
269 This alters the priority of the process before starting it.
271 .BR \-P ", " \-\-procsched " \fIpolicy\fP\fB:\fP\fIpriority\fP"
272 This alters the process scheduler policy and priority of the process before
273 starting it (since version 1.15.0).
274 The priority can be optionally specified by appending a \fB:\fP
275 followed by the value. The default \fIpriority\fP is 0. The currently
276 supported policy values are \fBother\fP, \fBfifo\fP and \fBrr\fP.
278 .BR \-I ", " \-\-iosched " \fIclass\fP\fB:\fP\fIpriority\fP"
279 This alters the IO scheduler class and priority of the process before starting
280 it (since version 1.15.0).
281 The priority can be optionally specified by appending a \fB:\fP followed
282 by the value. The default \fIpriority\fP is 4, unless \fIclass\fP is \fBidle\fP,
283 then \fIpriority\fP will always be 7. The currently supported values for
284 \fIclass\fP are \fBidle\fP, \fBbest-effort\fP and \fBreal-time\fP.
286 .BR \-k ", " \-\-umask " \fImask\fP"
287 This sets the umask of the process before starting it (since version 1.13.22).
289 .BR \-m ", " \-\-make\-pidfile
290 Used when starting a program that does not create its own pid file. This
292 .B start\-stop\-daemon
293 create the file referenced with
295 and place the pid into it just before executing the process. Note, the
296 file will only be removed when stopping the program if
297 \fB\-\-remove\-pidfile\fP is used.
299 This feature may not work in all cases. Most notably when the program
300 being executed forks from its main process. Because of this, it is usually
301 only useful when combined with the
305 .B \-\-remove\-pidfile
306 Used when stopping a program that does not remove its own pid file
307 (since version 1.17.19).
308 This option will make
309 .B start\-stop\-daemon
310 remove the file referenced with
312 after terminating the process.
314 .BR \-v ", " \-\-verbose
315 Print verbose informational messages.
320 The requested action was performed. If
322 was specified, it's also possible that nothing had to be done.
325 was specified and a matching process was already running, or when
327 was specified and there were no matching processes.
332 was not specified and nothing was done.
339 were specified, but the end of the schedule was reached and the processes were
345 When using the \fB\-\-status\fP command, the following status codes are
352 Program is not running and the pid file exists.
355 Program is not running.
358 Unable to determine program status.
361 Start the \fBfood\fP daemon, unless one is already running (a process named
362 food, running as user food, with pid in food.pid):
365 start\-stop\-daemon \-\-start \-\-oknodo \-\-user food \-\-name food \\
366 \-\-pidfile /run/food.pid \-\-startas /usr/sbin/food \\
367 \-\-chuid food \-\- \-\-daemon
370 Send \fBSIGTERM\fP to \fBfood\fP and wait up to 5 seconds for it to stop:
373 start\-stop\-daemon \-\-stop \-\-oknodo \-\-user food \-\-name food \\
374 \-\-pidfile /run/food.pid \-\-retry 5
377 Demonstration of a custom schedule for stopping \fBfood\fP:
380 start\-stop\-daemon \-\-stop \-\-oknodo \-\-user food \-\-name food \\
381 \-\-pidfile /run/food.pid \-\-retry=TERM/30/KILL/5