CRUX-ARM : Home

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