572 lines
15 KiB
HTML
572 lines
15 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of start-stop-daemon</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>start-stop-daemon</H1>
|
|
Section: dpkg suite (8)<BR>Updated: 2020-03-23<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
start-stop-daemon - start and stop system daemon programs
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>start-stop-daemon</B>
|
|
|
|
[<I>option</I>...] <I>command</I>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<B>start-stop-daemon</B>
|
|
|
|
is used to control the creation and termination of system-level processes.
|
|
Using one of the matching options, <B>start-stop-daemon</B>
|
|
can be configured to find existing instances of a running process.
|
|
<P>
|
|
|
|
Note: unless
|
|
<B>--pid</B>
|
|
|
|
or
|
|
<B>--pidfile</B>
|
|
|
|
are specified,
|
|
<B>start-stop-daemon</B>
|
|
|
|
behaves similar to
|
|
<B><A HREF="/cgi-bin/man/man2html?1+killall">killall</A></B>(1).
|
|
|
|
<B>start-stop-daemon</B>
|
|
|
|
will scan the process table looking for any processes which
|
|
match the process name, parent pid, uid, and/or gid (if specified). Any
|
|
matching process will prevent
|
|
<B>--start</B>
|
|
|
|
from starting the daemon. All matching processes will be sent the TERM
|
|
signal (or the one specified via <B>--signal</B> or <B>--retry</B>) if
|
|
<B>--stop</B>
|
|
|
|
is specified. For daemons which have long-lived children
|
|
which need to live through a
|
|
<B>--stop</B>,
|
|
|
|
you must specify a pidfile.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>COMMANDS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="1"><B>-S</B>, <B>--start</B> [<B>--</B>] <I>arguments</I>
|
|
|
|
<DD>
|
|
Check for the existence of a specified process.
|
|
If such a process exists,
|
|
<B>start-stop-daemon</B>
|
|
|
|
does nothing, and exits with error status 1 (0 if
|
|
<B>--oknodo</B>
|
|
|
|
is specified).
|
|
If such a process does not exist, it starts an
|
|
instance, using either the executable specified by
|
|
<B>--exec</B>
|
|
|
|
or, if specified, by
|
|
<B>--startas</B>.
|
|
|
|
Any arguments given after
|
|
<B>--</B>
|
|
|
|
on the command line are passed unmodified to the program being
|
|
started.
|
|
<DT id="2"><B>-K</B>, <B>--stop</B>
|
|
|
|
<DD>
|
|
Checks for the existence of a specified process.
|
|
If such a process exists,
|
|
<B>start-stop-daemon</B>
|
|
|
|
sends it the signal specified by
|
|
<B>--signal</B>,
|
|
|
|
and exits with error status 0.
|
|
If such a process does not exist,
|
|
<B>start-stop-daemon</B>
|
|
|
|
exits with error status 1
|
|
(0 if
|
|
<B>--oknodo</B>
|
|
|
|
is specified). If
|
|
<B>--retry</B>
|
|
|
|
is specified, then
|
|
<B>start-stop-daemon</B>
|
|
|
|
will check that the process(es) have terminated.
|
|
<DT id="3"><B>-T</B>, <B>--status</B>
|
|
|
|
<DD>
|
|
Check for the existence of a specified process, and returns an exit status
|
|
code, according to the LSB Init Script Actions (since version 1.16.1).
|
|
<DT id="4"><B>-H</B>, <B>--help</B>
|
|
|
|
<DD>
|
|
Show usage information and exit.
|
|
<DT id="5"><B>-V</B>, <B>--version</B>
|
|
|
|
<DD>
|
|
Show the program version and exit.
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>OPTIONS</H2>
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H3>Matching options</H3>
|
|
|
|
<DL COMPACT>
|
|
<DT id="6"><B>--pid</B> <I>pid</I>
|
|
|
|
<DD>
|
|
Check for a process with the specified <I>pid</I> (since version 1.17.6).
|
|
The <I>pid</I> must be a number greater than 0.
|
|
<DT id="7"><B>--ppid</B> <I>ppid</I>
|
|
|
|
<DD>
|
|
Check for a process with the specified parent pid <I>ppid</I>
|
|
(since version 1.17.7).
|
|
The <I>ppid</I> must be a number greater than 0.
|
|
<DT id="8"><B>-p</B>, <B>--pidfile</B> <I>pid-file</I>
|
|
|
|
<DD>
|
|
Check whether a process has created the file <I>pid-file</I>.
|
|
<DT id="9"><DD>
|
|
Note: using this matching option alone might cause unintended processes to
|
|
be acted on, if the old process terminated without being able to remove the
|
|
<I>pid-file</I>.
|
|
<DT id="10"><DD>
|
|
<B>Warning:</B> using this match option with a world-writable pidfile or using
|
|
it alone with a daemon that writes the pidfile as an unprivileged (non-root)
|
|
user will be refused with an error (since version 1.19.3) as this is a
|
|
security risk, because either any user can write to it, or if the daemon
|
|
gets compromised, the contents of the pidfile cannot be trusted, and then
|
|
a privileged runner (such as an init script executed as root) would end up
|
|
acting on any system process.
|
|
Using <I>/dev/null</I> is exempt from these checks.
|
|
<DT id="11"><B>-x</B>, <B>--exec</B> <I>executable</I>
|
|
|
|
<DD>
|
|
Check for processes that are instances of this <I>executable</I>. The
|
|
<I>executable</I> argument should be an absolute pathname. Note: this might
|
|
not work as intended with interpreted scripts, as the executable will point
|
|
to the interpreter. Take into account processes running from inside a chroot
|
|
will also be matched, so other match restrictions might be needed.
|
|
<DT id="12"><B>-n</B>, <B>--name</B> <I>process-name</I>
|
|
|
|
<DD>
|
|
Check for processes with the name <I>process-name</I>. The <I>process-name</I>
|
|
is usually the process filename, but it could have been changed by the
|
|
process itself. Note: on most systems this information is retrieved from
|
|
the process comm name from the kernel, which tends to have a relatively
|
|
short length limit (assuming more than 15 characters is non-portable).
|
|
<DT id="13"><B>-u</B>, <B>--user</B> <I>username</I>|<I>uid</I>
|
|
|
|
<DD>
|
|
Check for processes owned by the user specified by <I>username</I> or
|
|
<I>uid</I>. Note: using this matching option alone will cause all processes
|
|
matching the user to be acted on.
|
|
</DL>
|
|
<A NAME="lbAH"> </A>
|
|
<H3>Generic options</H3>
|
|
|
|
<DL COMPACT>
|
|
<DT id="14"><B>-g</B>, <B>--group</B> <I>group</I>|<I>gid</I>
|
|
|
|
<DD>
|
|
Change to <I>group</I> or <I>gid</I> when starting the process.
|
|
<DT id="15"><B>-s</B>, <B>--signal</B> <I>signal</I>
|
|
|
|
<DD>
|
|
With
|
|
<B>--stop</B>,
|
|
|
|
specifies the signal to send to processes being stopped (default TERM).
|
|
<DT id="16"><B>-R</B>, <B>--retry</B> <I>timeout</I>|<I>schedule</I>
|
|
|
|
<DD>
|
|
With
|
|
<B>--stop</B>,
|
|
|
|
specifies that
|
|
<B>start-stop-daemon</B>
|
|
|
|
is to check whether the process(es)
|
|
do finish. It will check repeatedly whether any matching processes
|
|
are running, until none are. If the processes do not exit it will
|
|
then take further action as determined by the schedule.
|
|
<P>
|
|
If
|
|
<I>timeout</I>
|
|
|
|
is specified instead of
|
|
<I>schedule</I>,
|
|
|
|
then the schedule
|
|
<I>signal</I><B>/</B><I>timeout</I><B>/KILL/</B><I>timeout</I>
|
|
|
|
is used, where
|
|
<I>signal</I>
|
|
|
|
is the signal specified with
|
|
<B>--signal</B>.
|
|
|
|
<P>
|
|
<I>schedule</I>
|
|
|
|
is a list of at least two items separated by slashes
|
|
(<B>/</B>);
|
|
|
|
each item may be
|
|
<B>-</B><I>signal-number</I>
|
|
|
|
or [<B>-</B>]<I>signal-name</I>,
|
|
which means to send that signal,
|
|
or
|
|
<I>timeout</I>,
|
|
|
|
which means to wait that many seconds for processes to
|
|
exit,
|
|
or
|
|
<B>forever</B>,
|
|
|
|
which means to repeat the rest of the schedule forever if
|
|
necessary.
|
|
<P>
|
|
If the end of the schedule is reached and
|
|
<B>forever</B>
|
|
|
|
is not specified, then
|
|
<B>start-stop-daemon</B>
|
|
|
|
exits with error status 2.
|
|
If a schedule is specified, then any signal specified
|
|
with
|
|
<B>--signal</B>
|
|
|
|
is ignored.
|
|
<DT id="17"><B>-a</B>, <B>--startas</B> <I>pathname</I>
|
|
|
|
<DD>
|
|
With
|
|
<B>--start</B>,
|
|
|
|
start the process specified by
|
|
<I>pathname</I>.
|
|
|
|
If not specified, defaults to the argument given to
|
|
<B>--exec</B>.
|
|
|
|
<DT id="18"><B>-t</B>, <B>--test</B>
|
|
|
|
<DD>
|
|
Print actions that would be taken and set appropriate return value,
|
|
but take no action.
|
|
<DT id="19"><B>-o</B>, <B>--oknodo</B>
|
|
|
|
<DD>
|
|
Return exit status 0 instead of 1 if no actions are (would be) taken.
|
|
<DT id="20"><B>-q</B>, <B>--quiet</B>
|
|
|
|
<DD>
|
|
Do not print informational messages; only display error messages.
|
|
<DT id="21"><B>-c</B>, <B>--chuid</B> <I>username</I>|<I>uid</I>[<B>:</B><I>group</I>|<I>gid</I>]
|
|
|
|
<DD>
|
|
Change to this username/uid before starting the process. You can also
|
|
specify a group by appending a
|
|
<B>:</B>,
|
|
|
|
then the group or gid in the same way
|
|
as you would for the <B><A HREF="/cgi-bin/man/man2html?1+chown">chown</A></B>(1) command (<I>user</I><B>:</B><I>group</I>).
|
|
If a user is specified without a group, the primary GID for that user is used.
|
|
When using this option
|
|
you must realize that the primary and supplemental groups are set as well,
|
|
even if the
|
|
<B>--group</B>
|
|
|
|
option is not specified. The
|
|
<B>--group</B>
|
|
|
|
option is only for
|
|
groups that the user isn't normally a member of (like adding per process
|
|
group membership for generic users like
|
|
<B>nobody</B>).
|
|
|
|
<DT id="22"><B>-r</B>, <B>--chroot</B> <I>root</I>
|
|
|
|
<DD>
|
|
Chdir and chroot to
|
|
<I>root</I>
|
|
|
|
before starting the process. Please note that the pidfile is also written
|
|
after the chroot.
|
|
<DT id="23"><B>-d</B>, <B>--chdir</B> <I>path</I>
|
|
|
|
<DD>
|
|
Chdir to
|
|
<I>path</I>
|
|
|
|
before starting the process. This is done after the chroot if the
|
|
<B>-r</B>|<B>--chroot</B> option is set. When not specified,
|
|
<B>start-stop-daemon</B>
|
|
|
|
will chdir to the root directory before starting the process.
|
|
<DT id="24"><B>-b</B>, <B>--background</B>
|
|
|
|
<DD>
|
|
Typically used with programs that don't detach on their own. This option
|
|
will force
|
|
<B>start-stop-daemon</B>
|
|
|
|
to fork before starting the process, and force it into the background.
|
|
<B>Warning: start-stop-daemon</B>
|
|
|
|
cannot check the exit status if the process fails to execute for
|
|
<B>any</B>
|
|
|
|
reason. This is a last resort, and is only meant for programs that either
|
|
make no sense forking on their own, or where it's not feasible to add the
|
|
code for them to do this themselves.
|
|
<DT id="25"><B>--notify-await</B>
|
|
|
|
<DD>
|
|
Wait for the background process to send a readiness notification before
|
|
considering the service started (since version 1.19.3).
|
|
This implements parts of the systemd readiness protocol, as specified
|
|
in the <B><A HREF="/cgi-bin/man/man2html?3+sd_notify">sd_notify</A></B>(3) man page.
|
|
The following variables are supported:
|
|
<DL COMPACT><DT id="26"><DD>
|
|
<DL COMPACT>
|
|
<DT id="27"><B>READY=1</B>
|
|
|
|
<DD>
|
|
The program is ready to give service, so we can exit safely.
|
|
<DT id="28"><B>EXTEND_TIMEOUT_USEC=</B><I>number</I>
|
|
|
|
<DD>
|
|
The program requests to extend the timeout by <I>number</I> microseconds.
|
|
This will reset the current timeout to the specified value.
|
|
<DT id="29"><B>ERRNO=</B><I>number</I>
|
|
|
|
<DD>
|
|
The program is exiting with an error.
|
|
Do the same and print the user-friendly string for the <B>errno</B> value.
|
|
</DL>
|
|
</DL>
|
|
|
|
<DT id="30"><B>--notify-timeout</B><I>timeout</I>
|
|
|
|
<DD>
|
|
Set a timeout for the <B>--notify-await</B> option (since version 1.19.3).
|
|
When the timeout is reached, <B>start-stop-daemon</B> will exit with an
|
|
error code, and no readiness notification will be awaited.
|
|
The default is <B>60</B> seconds.
|
|
<DT id="31"><B>-C</B>, <B>--no-close</B>
|
|
|
|
<DD>
|
|
Do not close any file descriptor when forcing the daemon into the background
|
|
(since version 1.16.5).
|
|
Used for debugging purposes to see the process output, or to redirect file
|
|
descriptors to log the process output.
|
|
Only relevant when using <B>--background</B>.
|
|
<DT id="32"><B>-N</B>, <B>--nicelevel</B> <I>int</I>
|
|
|
|
<DD>
|
|
This alters the priority of the process before starting it.
|
|
<DT id="33"><B>-P</B>, <B>--procsched</B> <I>policy</I><B>:</B><I>priority</I>
|
|
|
|
<DD>
|
|
This alters the process scheduler policy and priority of the process before
|
|
starting it (since version 1.15.0).
|
|
The priority can be optionally specified by appending a <B>:</B>
|
|
followed by the value. The default <I>priority</I> is 0. The currently
|
|
supported policy values are <B>other</B>, <B>fifo</B> and <B>rr</B>.
|
|
<DT id="34"><B>-I</B>, <B>--iosched</B> <I>class</I><B>:</B><I>priority</I>
|
|
|
|
<DD>
|
|
This alters the IO scheduler class and priority of the process before starting
|
|
it (since version 1.15.0).
|
|
The priority can be optionally specified by appending a <B>:</B> followed
|
|
by the value. The default <I>priority</I> is 4, unless <I>class</I> is <B>idle</B>,
|
|
then <I>priority</I> will always be 7. The currently supported values for
|
|
<I>class</I> are <B>idle</B>, <B>best-effort</B> and <B>real-time</B>.
|
|
<DT id="35"><B>-k</B>, <B>--umask</B> <I>mask</I>
|
|
|
|
<DD>
|
|
This sets the umask of the process before starting it (since version 1.13.22).
|
|
<DT id="36"><B>-m</B>, <B>--make-pidfile</B>
|
|
|
|
<DD>
|
|
Used when starting a program that does not create its own pid file. This
|
|
option will make
|
|
<B>start-stop-daemon</B>
|
|
|
|
create the file referenced with
|
|
<B>--pidfile</B>
|
|
|
|
and place the pid into it just before executing the process. Note, the
|
|
file will only be removed when stopping the program if
|
|
<B>--remove-pidfile</B> is used.
|
|
<B>Note:</B>
|
|
|
|
This feature may not work in all cases. Most notably when the program
|
|
being executed forks from its main process. Because of this, it is usually
|
|
only useful when combined with the
|
|
<B>--background</B>
|
|
|
|
option.
|
|
<DT id="37"><B>--remove-pidfile</B>
|
|
|
|
<DD>
|
|
Used when stopping a program that does not remove its own pid file
|
|
(since version 1.17.19).
|
|
This option will make
|
|
<B>start-stop-daemon</B>
|
|
|
|
remove the file referenced with
|
|
<B>--pidfile</B>
|
|
|
|
after terminating the process.
|
|
<DT id="38"><B>-v</B>, <B>--verbose</B>
|
|
|
|
<DD>
|
|
Print verbose informational messages.
|
|
</DL>
|
|
<A NAME="lbAI"> </A>
|
|
<H2>EXIT STATUS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="39"><B>0</B>
|
|
|
|
<DD>
|
|
The requested action was performed. If
|
|
<B>--oknodo</B>
|
|
|
|
was specified, it's also possible that nothing had to be done.
|
|
This can happen when
|
|
<B>--start</B>
|
|
|
|
was specified and a matching process was already running, or when
|
|
<B>--stop</B>
|
|
|
|
was specified and there were no matching processes.
|
|
<DT id="40"><B>1</B>
|
|
|
|
<DD>
|
|
If
|
|
<B>--oknodo</B>
|
|
|
|
was not specified and nothing was done.
|
|
<DT id="41"><B>2</B>
|
|
|
|
<DD>
|
|
If
|
|
<B>--stop</B>
|
|
|
|
and
|
|
<B>--retry</B>
|
|
|
|
were specified, but the end of the schedule was reached and the processes were
|
|
still running.
|
|
<DT id="42"><B>3</B>
|
|
|
|
<DD>
|
|
Any other error.
|
|
</DL>
|
|
<P>
|
|
|
|
When using the <B>--status</B> command, the following status codes are
|
|
returned:
|
|
<DL COMPACT>
|
|
<DT id="43"><B>0</B>
|
|
|
|
<DD>
|
|
Program is running.
|
|
<DT id="44"><B>1</B>
|
|
|
|
<DD>
|
|
Program is not running and the pid file exists.
|
|
<DT id="45"><B>3</B>
|
|
|
|
<DD>
|
|
Program is not running.
|
|
<DT id="46"><B>4</B>
|
|
|
|
<DD>
|
|
Unable to determine program status.
|
|
</DL>
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>EXAMPLE</H2>
|
|
|
|
Start the <B>food</B> daemon, unless one is already running (a process named
|
|
food, running as user food, with pid in food.pid):
|
|
<DL COMPACT>
|
|
<DT id="47"><DD>
|
|
<PRE>
|
|
start-stop-daemon --start --oknodo --user food --name food \
|
|
--pidfile /run/food.pid --startas /usr/sbin/food \
|
|
--chuid food -- --daemon
|
|
</PRE>
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
Send <B>SIGTERM</B> to <B>food</B> and wait up to 5 seconds for it to stop:
|
|
<DL COMPACT>
|
|
<DT id="48"><DD>
|
|
<PRE>
|
|
start-stop-daemon --stop --oknodo --user food --name food \
|
|
--pidfile /run/food.pid --retry 5
|
|
</PRE>
|
|
|
|
</DL>
|
|
<P>
|
|
|
|
Demonstration of a custom schedule for stopping <B>food</B>:
|
|
<DL COMPACT>
|
|
<DT id="49"><DD>
|
|
<PRE>
|
|
start-stop-daemon --stop --oknodo --user food --name food \
|
|
--pidfile /run/food.pid --retry=TERM/30/KILL/5
|
|
</PRE>
|
|
|
|
<P>
|
|
</DL>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="50"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="51"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="52"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="53"><A HREF="#lbAE">COMMANDS</A><DD>
|
|
<DT id="54"><A HREF="#lbAF">OPTIONS</A><DD>
|
|
<DL>
|
|
<DT id="55"><A HREF="#lbAG">Matching options</A><DD>
|
|
<DT id="56"><A HREF="#lbAH">Generic options</A><DD>
|
|
</DL>
|
|
<DT id="57"><A HREF="#lbAI">EXIT STATUS</A><DD>
|
|
<DT id="58"><A HREF="#lbAJ">EXAMPLE</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:06:16 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|