CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
start-stop-daemon: updated to 20170812
[crossrootfs.git] / start-stop-daemon / start-stop-daemon.8
CommitLineData
487cc3be
VM
1.\" dpkg manual page - start-stop-daemon(8)
2.\"
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>
9.\"
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.
14.\"
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.
19.\"
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/>.
22.
c653e22c
VM
23.TH start\-stop\-daemon 8 "2017-07-04" "Debian Project" "dpkg suite"
24.nh
487cc3be
VM
25.SH NAME
26start\-stop\-daemon \- start and stop system daemon programs
27.
28.SH SYNOPSIS
29.B start\-stop\-daemon
30.RI [ option "...] " command
31.
32.SH DESCRIPTION
33.B start\-stop\-daemon
34is used to control the creation and termination of system-level processes.
35Using one of the matching options, \fBstart\-stop\-daemon\fP
36can be configured to find existing instances of a running process.
37.PP
38Note: unless
39.B \-\-pid
40or
41.B \-\-pidfile
42are specified,
43.B start\-stop\-daemon
44behaves similar to
45.BR killall (1).
46.B start\-stop\-daemon
47will scan the process table looking for any processes which
48match the process name, parent pid, uid, and/or gid (if specified). Any
49matching process will prevent
50.BR \-\-start
51from starting the daemon. All matching processes will be sent the TERM
52signal (or the one specified via \fB\-\-signal\fP or \fB\-\-retry\fP) if
53.BR \-\-stop
54is specified. For daemons which have long-lived children
55which need to live through a
56.BR \-\-stop ,
57you must specify a pidfile.
58.
59.SH COMMANDS
60.TP
61.BR \-S ", " \-\-start " [" \-\- "] \fIarguments\fP"
62Check for the existence of a specified process.
63If such a process exists,
64.B start\-stop\-daemon
65does nothing, and exits with error status 1 (0 if
66.BR \-\-oknodo
67is specified).
68If such a process does not exist, it starts an
69instance, using either the executable specified by
70.B \-\-exec
71or, if specified, by
72.BR \-\-startas .
73Any arguments given after
74.BR \-\-
75on the command line are passed unmodified to the program being
76started.
77.TP
78.BR \-K ", " \-\-stop
79Checks for the existence of a specified process.
80If such a process exists,
81.B start\-stop\-daemon
82sends it the signal specified by
83.BR \-\-signal ,
84and exits with error status 0.
85If such a process does not exist,
86.B start\-stop\-daemon
87exits with error status 1
88(0 if
89.BR \-\-oknodo
90is specified). If
91.B \-\-retry
92is specified, then
93.B start\-stop\-daemon
94will check that the process(es) have terminated.
95.TP
96.BR \-T ", " \-\-status
97Check for the existence of a specified process, and returns an exit status
98code, according to the LSB Init Script Actions (since version 1.16.1).
99.TP
100.BR \-H ", " \-\-help
101Show usage information and exit.
102.TP
103.BR \-V ", " \-\-version
104Show the program version and exit.
105.
106.SH OPTIONS
107.SS Matching options
108.TP
109.BR \-\-pid " \fIpid\fP"
110Check for a process with the specified \fIpid\fP (since version 1.17.6).
111The \fIpid\fP must be a number greater than 0.
112.TP
113.BR \-\-ppid " \fIppid\fP"
114Check for a process with the specified parent pid \fIppid\fP
115(since version 1.17.7).
116The \fIppid\fP must be a number greater than 0.
117.TP
118.BR \-p ", " \-\-pidfile " \fIpid-file\fP"
119Check whether a process has created the file \fIpid-file\fP. Note: using this
120matching option alone might cause unintended processes to be acted on, if the
121old process terminated without being able to remove the \fIpid-file\fP.
122.TP
123.BR \-x ", " \-\-exec " \fIexecutable\fP"
124Check for processes that are instances of this \fIexecutable\fP. The
125\fIexecutable\fP argument should be an absolute pathname. Note: this might
126not work as intended with interpreted scripts, as the executable will point
127to the interpreter. Take into account processes running from inside a chroot
128will also be matched, so other match restrictions might be needed.
129.TP
130.BR \-n ", " \-\-name " \fIprocess-name\fP"
131Check for processes with the name \fIprocess-name\fP. The \fIprocess-name\fP
132is usually the process filename, but it could have been changed by the
133process itself. Note: on most systems this information is retrieved from
134the process comm name from the kernel, which tends to have a relatively
135short length limit (assuming more than 15 characters is non-portable).
136.TP
137.BR \-u ", " \-\-user " \fIusername\fP|\fIuid\fP
138Check for processes owned by the user specified by \fIusername\fP or
139\fIuid\fP. Note: using this matching option alone will cause all processes
140matching the user to be acted on.
141.
142.SS Generic options
143.TP
144.BR \-g ", " \-\-group " \fIgroup\fP|\fIgid\fP"
145Change to \fIgroup\fP or \fIgid\fP when starting the process.
146.TP
147.BR \-s ", " \-\-signal " \fIsignal\fP"
148With
149.BR \-\-stop ,
150specifies the signal to send to processes being stopped (default TERM).
151.TP
152.BR \-R ", " \-\-retry " \fItimeout\fP|\fIschedule\fP"
153With
154.BR \-\-stop ,
155specifies that
156.B start\-stop\-daemon
157is to check whether the process(es)
158do finish. It will check repeatedly whether any matching processes
159are running, until none are. If the processes do not exit it will
160then take further action as determined by the schedule.
161
162If
163.I timeout
164is specified instead of
165.IR schedule ,
166then the schedule
167.IB signal / timeout /KILL/ timeout
168is used, where
169.I signal
170is the signal specified with
171.BR \-\-signal .
172
173.I schedule
174is a list of at least two items separated by slashes
175.RB ( / );
176each item may be
177.BI \- signal-number
178or [\fB\-\fP]\fIsignal-name\fP,
179which means to send that signal,
180or
181.IR timeout ,
182which means to wait that many seconds for processes to
183exit,
184or
185.BR forever ,
186which means to repeat the rest of the schedule forever if
187necessary.
188
189If the end of the schedule is reached and
190.BR forever
191is not specified, then
192.B start\-stop\-daemon
193exits with error status 2.
194If a schedule is specified, then any signal specified
195with
196.B \-\-signal
197is ignored.
198.TP
199.BR \-a ", " \-\-startas " \fIpathname\fP"
200With
201.BR \-\-start ,
202start the process specified by
203.IR pathname .
204If not specified, defaults to the argument given to
205.BR \-\-exec .
206.TP
207.BR \-t ", " \-\-test
208Print actions that would be taken and set appropriate return value,
209but take no action.
210.TP
211.BR \-o ", " \-\-oknodo
212Return exit status 0 instead of 1 if no actions are (would be) taken.
213.TP
214.BR \-q ", " \-\-quiet
215Do not print informational messages; only display error messages.
216.TP
217.BR \-c ", " \-\-chuid " \fIusername\fR|\fIuid\fP[\fB:\fP\fIgroup\fR|\fIgid\fP]"
218Change to this username/uid before starting the process. You can also
219specify a group by appending a
220.BR : ,
221then the group or gid in the same way
222as you would for the \fBchown\fP(1) command (\fIuser\fP\fB:\fP\fIgroup\fP).
223If a user is specified without a group, the primary GID for that user is used.
224When using this option
225you must realize that the primary and supplemental groups are set as well,
226even if the
227.B \-\-group
228option is not specified. The
229.B \-\-group
230option is only for
231groups that the user isn't normally a member of (like adding per process
232group membership for generic users like
233.BR nobody ).
234.TP
235.BR \-r ", " \-\-chroot " \fIroot\fP"
236Chdir and chroot to
237.I root
238before starting the process. Please note that the pidfile is also written
239after the chroot.
240.TP
241.BR \-d ", " \-\-chdir " \fIpath\fP"
242Chdir to
243.I path
244before 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
247will chdir to the root directory before starting the process.
248.TP
249.BR \-b ", " \-\-background
250Typically used with programs that don't detach on their own. This option
251will force
252.B start\-stop\-daemon
253to fork before starting the process, and force it into the background.
254.B Warning: start\-stop\-daemon
255cannot check the exit status if the process fails to execute for
256.B any
257reason. This is a last resort, and is only meant for programs that either
258make no sense forking on their own, or where it's not feasible to add the
259code for them to do this themselves.
260.TP
261.BR \-C ", " \-\-no\-close
262Do not close any file descriptor when forcing the daemon into the background
263(since version 1.16.5).
264Used for debugging purposes to see the process output, or to redirect file
265descriptors to log the process output.
266Only relevant when using \fB\-\-background\fP.
267.TP
268.BR \-N ", " \-\-nicelevel " \fIint\fP"
269This alters the priority of the process before starting it.
270.TP
271.BR \-P ", " \-\-procsched " \fIpolicy\fP\fB:\fP\fIpriority\fP"
272This alters the process scheduler policy and priority of the process before
273starting it (since version 1.15.0).
274The priority can be optionally specified by appending a \fB:\fP
275followed by the value. The default \fIpriority\fP is 0. The currently
276supported policy values are \fBother\fP, \fBfifo\fP and \fBrr\fP.
277.TP
278.BR \-I ", " \-\-iosched " \fIclass\fP\fB:\fP\fIpriority\fP"
279This alters the IO scheduler class and priority of the process before starting
280it (since version 1.15.0).
281The priority can be optionally specified by appending a \fB:\fP followed
282by the value. The default \fIpriority\fP is 4, unless \fIclass\fP is \fBidle\fP,
283then \fIpriority\fP will always be 7. The currently supported values for
284\fIclass\fP are \fBidle\fP, \fBbest-effort\fP and \fBreal-time\fP.
285.TP
286.BR \-k ", " \-\-umask " \fImask\fP"
287This sets the umask of the process before starting it (since version 1.13.22).
288.TP
289.BR \-m ", " \-\-make\-pidfile
290Used when starting a program that does not create its own pid file. This
291option will make
292.B start\-stop\-daemon
293create the file referenced with
294.B \-\-pidfile
295and place the pid into it just before executing the process. Note, the
296file will only be removed when stopping the program if
297\fB\-\-remove\-pidfile\fP is used.
298.B Note:
299This feature may not work in all cases. Most notably when the program
300being executed forks from its main process. Because of this, it is usually
301only useful when combined with the
302.B \-\-background
303option.
304.TP
305.B \-\-remove\-pidfile
306Used when stopping a program that does not remove its own pid file
307(since version 1.17.19).
308This option will make
309.B start\-stop\-daemon
310remove the file referenced with
311.B \-\-pidfile
312after terminating the process.
313.TP
314.BR \-v ", " \-\-verbose
315Print verbose informational messages.
316.
317.SH EXIT STATUS
318.TP
319.B 0
320The requested action was performed. If
321.B \-\-oknodo
322was specified, it's also possible that nothing had to be done.
323This can happen when
324.B \-\-start
325was specified and a matching process was already running, or when
326.B \-\-stop
327was specified and there were no matching processes.
328.TP
329.B 1
330If
331.B \-\-oknodo
332was not specified and nothing was done.
333.TP
334.B 2
335If
336.B \-\-stop
337and
338.B \-\-retry
339were specified, but the end of the schedule was reached and the processes were
340still running.
341.TP
342.B 3
343Any other error.
344.PP
345When using the \fB\-\-status\fP command, the following status codes are
346returned:
347.TP
348.B 0
349Program is running.
350.TP
351.B 1
352Program is not running and the pid file exists.
353.TP
354.B 3
355Program is not running.
356.TP
357.B 4
358Unable to determine program status.
359.
360.SH EXAMPLE
361Start the \fBfood\fP daemon, unless one is already running (a process named
362food, running as user food, with pid in food.pid):
363.IP
364.nf
365start\-stop\-daemon \-\-start \-\-oknodo \-\-user food \-\-name food \\
366 \-\-pidfile /run/food.pid \-\-startas /usr/sbin/food \\
367 \-\-chuid food \-\- \-\-daemon
368.fi
369.PP
370Send \fBSIGTERM\fP to \fBfood\fP and wait up to 5 seconds for it to stop:
371.IP
372.nf
373start\-stop\-daemon \-\-stop \-\-oknodo \-\-user food \-\-name food \\
374 \-\-pidfile /run/food.pid \-\-retry 5
375.fi
376.PP
377Demonstration of a custom schedule for stopping \fBfood\fP:
378.IP
379.nf
380start\-stop\-daemon \-\-stop \-\-oknodo \-\-user food \-\-name food \\
381 \-\-pidfile /run/food.pid \-\-retry=TERM/30/KILL/5
382.fi