]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/systemd.service.xml
core: fix detection of dead processes
[thirdparty/systemd.git] / man / systemd.service.xml
CommitLineData
d1ab0ca0
LP
1<?xml version='1.0'?> <!--*-nxml-*-->
2<?xml-stylesheet type="text/xsl" href="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"?>
3<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
4 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
5
6<!--
7 This file is part of systemd.
8
9 Copyright 2010 Lennart Poettering
10
11 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
12 under the terms of the GNU Lesser General Public License as published by
13 the Free Software Foundation; either version 2.1 of the License, or
d1ab0ca0
LP
14 (at your option) any later version.
15
16 systemd is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2 19 Lesser General Public License for more details.
d1ab0ca0 20
5430f7f2 21 You should have received a copy of the GNU Lesser General Public License
d1ab0ca0
LP
22 along with systemd; If not, see <http://www.gnu.org/licenses/>.
23-->
24
25<refentry id="systemd.service">
26 <refentryinfo>
27 <title>systemd.service</title>
28 <productname>systemd</productname>
29
30 <authorgroup>
31 <author>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
36 </author>
37 </authorgroup>
38 </refentryinfo>
39
40 <refmeta>
41 <refentrytitle>systemd.service</refentrytitle>
42 <manvolnum>5</manvolnum>
43 </refmeta>
44
45 <refnamediv>
46 <refname>systemd.service</refname>
34511ca7 47 <refpurpose>Service unit configuration</refpurpose>
d1ab0ca0
LP
48 </refnamediv>
49
50 <refsynopsisdiv>
e670b166 51 <para><filename><replaceable>service</replaceable>.service</filename></para>
d1ab0ca0
LP
52 </refsynopsisdiv>
53
54 <refsect1>
55 <title>Description</title>
56
1f812fea 57 <para>A unit configuration file whose name ends in
65232ea7
LP
58 <filename>.service</filename> encodes information
59 about a process controlled and supervised by
60 systemd.</para>
d1ab0ca0
LP
61
62 <para>This man page lists the configuration options
63 specific to this unit type. See
64 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
65 for the common options of all unit configuration
0d624a78 66 files. The common configuration items are configured
62adf224
LP
67 in the generic <literal>[Unit]</literal> and
68 <literal>[Install]</literal> sections. The service
69 specific configuration options are configured in the
70 <literal>[Service]</literal> section.</para>
0d624a78 71
ba60f905
LP
72 <para>Additional options are listed in
73 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
74 which define the execution environment the commands
4819ff03 75 are executed in, and in
d868475a 76 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
4819ff03 77 which define the way the processes of the service are
d868475a 78 terminated, and in
3fde5f30
LP
79 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
80 which configure resource control settings for the
d868475a 81 processes of the service.</para>
62adf224
LP
82
83 <para>Unless <varname>DefaultDependencies=</varname>
84 is set to <option>false</option>, service units will
85 implicitly have dependencies of type
86 <varname>Requires=</varname> and
87 <varname>After=</varname> on
88 <filename>basic.target</filename> as well as
89 dependencies of type <varname>Conflicts=</varname> and
90 <varname>Before=</varname> on
91 <filename>shutdown.target</filename>. These ensure
92 that normal service units pull in basic system
93 initialization, and are terminated cleanly prior to
94 system shutdown. Only services involved with early
95 boot or late system shutdown should disable this
96 option.</para>
59a3e1bc
LP
97
98 <para>If a service is requested under a certain name
99 but no unit configuration file is found, systemd looks
100 for a SysV init script by the same name (with the
101 <filename>.service</filename> suffix removed) and
102 dynamically creates a service unit from that
103 script. This is useful for compatibility with
99800333
LP
104 SysV. Note that this compatibility is quite
105 comprehensive but not 100%. For details about the
bb31a4ac 106 incompatibilities see the <ulink
99800333
LP
107 url="http://www.freedesktop.org/wiki/Software/systemd/Incompatibilities">Incompatibilities
108 with SysV</ulink> document.
109 </para>
d1ab0ca0
LP
110 </refsect1>
111
112 <refsect1>
113 <title>Options</title>
114
62adf224
LP
115 <para>Service files must include a
116 <literal>[Service]</literal> section, which carries
117 information about the service and the process it
118 supervises. A number of options that may be used in
119 this section are shared with other unit types. These
120 options are documented in
4819ff03
LP
121 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
122 and
123 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>. The
62adf224
LP
124 options specific to the <literal>[Service]</literal>
125 section of service units are the following:</para>
0d624a78 126
ccc9a4f9 127 <variablelist class='unit-directives'>
d1ab0ca0
LP
128 <varlistentry>
129 <term><varname>Type=</varname></term>
0d624a78
LP
130
131 <listitem><para>Configures the process
132 start-up type for this service
133 unit. One of <option>simple</option>,
134 <option>forking</option>,
34e9ba66 135 <option>oneshot</option>,
0d624a78 136 <option>dbus</option>,
a8ad0f89
LP
137 <option>notify</option> or
138 <option>idle</option>.</para>
0d624a78
LP
139
140 <para>If set to
141 <option>simple</option> (the default
12b25f30
ZJS
142 value if neither
143 <varname>Type=</varname> nor
144 <varname>BusName=</varname> are
145 specified), it is expected that the
146 process configured with
0d624a78
LP
147 <varname>ExecStart=</varname> is the
148 main process of the service. In this
b1690fe7
LP
149 mode, if the process offers
150 functionality to other processes on
79640424 151 the system, its communication channels
b1690fe7
LP
152 should be installed before the daemon
153 is started up (e.g. sockets set up by
154 systemd, via socket activation), as
155 systemd will immediately proceed
156 starting follow-up units.</para>
0d624a78
LP
157
158 <para>If set to
79640424 159 <option>forking</option>, it is
0d624a78
LP
160 expected that the process configured
161 with <varname>ExecStart=</varname>
b1690fe7
LP
162 will call <function>fork()</function>
163 as part of its start-up. The parent process is
164 expected to exit when start-up is
165 complete and all communication
79640424 166 channels are set up. The child continues
b1690fe7 167 to run as the main daemon
c5315881 168 process. This is the behavior of
b1690fe7 169 traditional UNIX daemons. If this
0d624a78
LP
170 setting is used, it is recommended to
171 also use the
172 <varname>PIDFile=</varname> option, so
173 that systemd can identify the main
174 process of the daemon. systemd will
175 proceed starting follow-up units as
176 soon as the parent process
177 exits.</para>
178
c5315881 179 <para>Behavior of
34e9ba66 180 <option>oneshot</option> is similar
0d624a78
LP
181 to <option>simple</option>, however
182 it is expected that the process has to
183 exit before systemd starts follow-up
02ee865a 184 units. <varname>RemainAfterExit=</varname>
0d624a78
LP
185 is particularly useful for this type
186 of service.</para>
187
c5315881 188 <para>Behavior of
0d624a78 189 <option>dbus</option> is similar to
62adf224
LP
190 <option>simple</option>, however it is
191 expected that the daemon acquires a
0d624a78
LP
192 name on the D-Bus bus, as configured
193 by
194 <varname>BusName=</varname>. systemd
195 will proceed starting follow-up units
196 after the D-Bus bus name has been
62adf224 197 acquired. Service units with this
b1690fe7 198 option configured implicitly gain
62adf224 199 dependencies on the
177b3ffe 200 <filename>dbus.socket</filename>
0b86feac
LP
201 unit. This type is the default if
202 <varname>BusName=</varname> is
203 specified.</para>
0d624a78 204
c5315881 205 <para>Behavior of
0d624a78
LP
206 <option>notify</option> is similar to
207 <option>simple</option>, however it is
208 expected that the daemon sends a
209 notification message via
210 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>
211 or an equivalent call when it finished
212 starting up. systemd will proceed
213 starting follow-up units after this
214 notification message has been sent. If
79640424 215 this option is used,
62adf224 216 <varname>NotifyAccess=</varname> (see
b1690fe7 217 below) should be set to open access to
0d624a78 218 the notification socket provided by
62adf224 219 systemd. If
02c4ef9c
LP
220 <varname>NotifyAccess=</varname> is
221 not set, it will be implicitly set to
1361a3e3
LP
222 <option>main</option>. Note that
223 currently
224 <varname>Type=</varname><option>notify</option>
79640424 225 will not work if used in combination with
1361a3e3 226 <varname>PrivateNetwork=</varname><option>yes</option>.</para>
a8ad0f89 227
c5315881 228 <para>Behavior of
a8ad0f89 229 <option>idle</option> is very similar
349b915d 230 to <option>simple</option>, however
bb31a4ac 231 actual execution of the service
a8ad0f89
LP
232 binary is delayed until all jobs are
233 dispatched. This may be used to avoid
234 interleaving of output of shell
235 services with the status output on the
236 console.</para>
d1ab0ca0
LP
237 </listitem>
238 </varlistentry>
0d624a78 239
d1ab0ca0 240 <varlistentry>
02ee865a 241 <term><varname>RemainAfterExit=</varname></term>
0d624a78
LP
242
243 <listitem><para>Takes a boolean value
244 that specifies whether the service
245 shall be considered active even when
246 all its processes exited. Defaults to
247 <option>no</option>.</para>
d1ab0ca0 248 </listitem>
3185a36b
LP
249 </varlistentry>
250
251 <varlistentry>
252 <term><varname>GuessMainPID=</varname></term>
253
254 <listitem><para>Takes a boolean value
255 that specifies whether systemd should
256 try to guess the main PID of a service
bb31a4ac 257 if it cannot be determined
3185a36b
LP
258 reliably. This option is ignored
259 unless <option>Type=forking</option>
260 is set and <option>PIDFile=</option>
261 is unset because for the other types
262 or with an explicitly configured PID
263 file the main PID is always known. The
264 guessing algorithm might come to
265 incorrect conclusions if a daemon
266 consists of more than one process. If
79640424 267 the main PID cannot be determined,
3185a36b
LP
268 failure detection and automatic
269 restarting of a service will not work
270 reliably. Defaults to
271 <option>yes</option>.</para>
272 </listitem>
d1ab0ca0
LP
273 </varlistentry>
274
275 <varlistentry>
276 <term><varname>PIDFile=</varname></term>
0d624a78
LP
277
278 <listitem><para>Takes an absolute file
279 name pointing to the PID file of this
280 daemon. Use of this option is
281 recommended for services where
282 <varname>Type=</varname> is set to
be039669
LP
283 <option>forking</option>. systemd will
284 read the PID of the main process of
285 the daemon after start-up of the
286 service. systemd will not write to the
287 file configured here.</para>
d1ab0ca0
LP
288 </listitem>
289 </varlistentry>
290
291 <varlistentry>
292 <term><varname>BusName=</varname></term>
0d624a78
LP
293
294 <listitem><para>Takes a D-Bus bus
bb31a4ac 295 name, that this service is reachable
0d624a78
LP
296 as. This option is mandatory for
297 services where
298 <varname>Type=</varname> is set to
299 <option>dbus</option>, but its use
300 is otherwise recommended as well if
301 the process takes a name on the D-Bus
302 bus.</para>
d1ab0ca0
LP
303 </listitem>
304 </varlistentry>
305
306 <varlistentry>
307 <term><varname>ExecStart=</varname></term>
22f38abe
LP
308 <listitem><para>Commands with their
309 arguments that are executed when this
ec6039bc
ZJS
310 service is started. For each of the
311 specified commands, the first argument
312 must be an absolute and literal path
313 to an executable.</para>
2480f0c6 314
4c42e8e1
ZJS
315 <para>When <varname>Type</varname> is
316 not <option>oneshot</option>, only one
317 command may be given. When
b1690fe7 318 <varname>Type=oneshot</varname> is
2480f0c6
ZJS
319 used, more than one command may be
320 specified. Multiple command lines may
321 be concatenated in a single directive,
322 by separating them with semicolons
323 (these semicolons must be passed as
324 separate words). Alternatively, this
325 directive may be specified more than
6baf995c 326 once with the same effect.
4c42e8e1 327 Lone semicolons may be escaped as
909f413d 328 <literal>\;</literal>. If the empty
79640424 329 string is assigned to this option, the
74051b9b
LP
330 list of commands to start is reset,
331 prior assignments of this option will
332 have no effect.</para>
2480f0c6 333
ec6039bc
ZJS
334 <para>Each command line is split on
335 whitespace, with the first item being
336 the command to execute, and the
337 subsequent items being the arguments.
338 Double quotes ("...") and single
339 quotes ('...') may be used, in which
340 case everything until the next
341 matching quote becomes part of the
342 same argument. Quotes themselves are
343 removed after parsing. In addition, a
344 trailing backslash
345 (<literal>\</literal>) may be used to
346 merge lines. This syntax is intended
347 to be very similar to shell syntax,
348 but only the meta-characters and
349 expansions described in the following
350 paragraphs are understood.
351 Specifically, redirection using
352 <literal>&lt;</literal>,
353 <literal>&lt;&lt;</literal>,
354 <literal>&gt;</literal>, and
355 <literal>&gt;&gt;</literal>, pipes
356 using <literal>|</literal>, and
357 running programs in the background
358 using <literal>&amp;</literal>
359 and <emphasis>other elements of shell
360 syntax are not supported</emphasis>.
361 </para>
362
4c42e8e1
ZJS
363 <para>If more than one command is
364 specified, the commands are invoked
365 one by one sequentially in the order
366 they appear in the unit file. If one
367 of the commands fails (and is not
909f413d 368 prefixed with <literal>-</literal>),
4c42e8e1
ZJS
369 other lines are not executed and the
370 unit is considered failed.</para>
371
2480f0c6
ZJS
372 <para>Unless
373 <varname>Type=forking</varname> is
374 set, the process started via this
375 command line will be considered the
22f38abe
LP
376 main process of the daemon.</para>
377
378 <para>The command line accepts
909f413d 379 <literal>%</literal> specifiers as
22f38abe 380 described in
ec6039bc
ZJS
381 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
382 Note that the first argument of the
383 command line (i.e. the program to
384 execute) may not include
385 specifiers.</para>
b1690fe7 386
4c42e8e1
ZJS
387 <para>Basic environment variable
388 substitution is supported. Use
7734f773 389 <literal>${FOO}</literal> as part of a
bb31a4ac 390 word, or as a word of its own on the
7734f773
BS
391 command line, in which case it will be
392 replaced by the value of the
393 environment variable including all
394 whitespace it contains, resulting in a
c5b37953 395 single argument. Use
7734f773
BS
396 <literal>$FOO</literal> as a separate
397 word on the command line, in which
398 case it will be replaced by the value
c5b37953
ZJS
399 of the environment variable split at
400 whitespace, resulting in zero or more
401 arguments. To pass a literal dollar
402 sign, use <literal>$$</literal>.
403 Variables whose value is not known at
404 expansion time are treated as empty
405 strings. Note that the first argument
406 (i.e. the program to execute) may not
407 be a variable.</para>
408
409 <para>Variables to be used in this
410 fashion may be defined through
411 <varname>Environment=</varname> and
412 <varname>EnvironmentFile=</varname>.
413 In addition, variables listed in
414 section "Environment variables in
415 spawned processes" in
416 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
417 which are considered "static
418 configuration" may used (this includes
419 e.g. <varname>$USER</varname>, but not
420 <varname>$TERM</varname>).</para>
a2927192 421
74051b9b
LP
422 <para>Optionally, if the absolute file
423 name is prefixed with
909f413d 424 <literal>@</literal>, the second token
74051b9b
LP
425 will be passed as
426 <literal>argv[0]</literal> to the
427 executed process, followed by the
428 further arguments specified. If the
e9dd9f95 429 absolute filename is prefixed with
79640424 430 <literal>-</literal>, an exit code of
74051b9b
LP
431 the command normally considered a
432 failure (i.e. non-zero exit status or
433 abnormal exit due to signal) is ignored
434 and considered success. If both
909f413d 435 <literal>-</literal> and
79640424 436 <literal>@</literal> are used, they
74051b9b
LP
437 can appear in either order.</para>
438
a2927192
LP
439 <para>Note that this setting does not
440 directly support shell command
441 lines. If shell command lines are to
79640424 442 be used, they need to be passed
a2927192 443 explicitly to a shell implementation
4c42e8e1 444 of some kind. Example:</para>
9fccdb0f 445 <programlisting>ExecStart=/bin/sh -c 'dmesg | tac'</programlisting>
ec6039bc 446 <para>Example:</para>
9fccdb0f 447 <programlisting>ExecStart=/bin/echo one ; /bin/echo "two two"</programlisting>
ec6039bc
ZJS
448 <para>This will execute
449 <command>/bin/echo</command> two
450 times, each time with one argument,
451 <literal>one</literal> and
452 <literal>two two</literal>,
453 respectively. Since two commands are
b040723e 454 specified,
ec6039bc
ZJS
455 <varname>Type=oneshot</varname> must
456 be used.</para>
457
458 <para>Example:</para>
459 <programlisting>ExecStart=/bin/echo / &gt;/dev/null &amp; \; \
9fccdb0f 460/bin/ls</programlisting>
ec6039bc
ZJS
461 <para>This will execute
462 <command>/bin/echo</command> with five
463 arguments: <literal>/</literal>,
464 <literal>&gt;/dev/null</literal>,
465 <literal>&amp;</literal>,
466 <literal>;</literal>, and
467 <literal>/bin/ls</literal>.</para>
468
469 <para>Example:</para>
470 <programlisting>Environment="ONE=one" 'TWO=two two'
9fccdb0f 471ExecStart=/bin/echo $ONE $TWO ${TWO}</programlisting>
ec6039bc
ZJS
472 <para>This will execute
473 <command>/bin/echo</command> with four
474 arguments: <literal>one</literal>,
475 <literal>two</literal>,
476 <literal>two</literal>, and
477 <literal>two two</literal>.</para>
478 </listitem>
0d624a78
LP
479 </varlistentry>
480
481 <varlistentry>
482 <term><varname>ExecStartPre=</varname></term>
483 <term><varname>ExecStartPost=</varname></term>
484 <listitem><para>Additional commands
16dad32e 485 that are executed before or after
0d624a78 486 the command in
2480f0c6
ZJS
487 <varname>ExecStart=</varname>, respectively.
488 Syntax is the same as for
489 <varname>ExecStart=</varname>, except
490 that multiple command lines are allowed
491 and the commands are executed one
492 after the other, serially.</para>
4c42e8e1
ZJS
493
494 <para>If any of those commands (not
909f413d 495 prefixed with <literal>-</literal>)
4c42e8e1
ZJS
496 fail, the rest are not executed and
497 the unit is considered failed.</para>
2480f0c6 498 </listitem>
0d624a78
LP
499 </varlistentry>
500
501 <varlistentry>
502 <term><varname>ExecReload=</varname></term>
503 <listitem><para>Commands to execute to
504 trigger a configuration reload in the
b3eaa628
LP
505 service. This argument takes multiple
506 command lines, following the same
2480f0c6
ZJS
507 scheme as described for
508 <varname>ExecStart=</varname>
b3eaa628 509 above. Use of this setting is
420a0166
LP
510 optional. Specifier and environment
511 variable substitution is supported
512 here following the same scheme as for
4c42e8e1
ZJS
513 <varname>ExecStart=</varname>.</para>
514
515 <para>One additional special
516 environment variables is set: if known
517 <varname>$MAINPID</varname> is set to
97ae63e2
LP
518 the main process of the daemon, and
519 may be used for command lines like the
4c42e8e1
ZJS
520 following:</para>
521
522 <programlisting>/bin/kill -HUP $MAINPID</programlisting>
523 </listitem>
0d624a78
LP
524 </varlistentry>
525
526 <varlistentry>
527 <term><varname>ExecStop=</varname></term>
528 <listitem><para>Commands to execute to
529 stop the service started via
b3eaa628
LP
530 <varname>ExecStart=</varname>. This
531 argument takes multiple command lines,
2480f0c6
ZJS
532 following the same scheme as described
533 for <varname>ExecStart=</varname>
b3eaa628 534 above. Use of this setting is
0d624a78
LP
535 optional. All processes remaining for
536 a service after the commands
537 configured in this option are run are
538 terminated according to the
539 <varname>KillMode=</varname> setting
4819ff03
LP
540 (see
541 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>). If
79640424 542 this option is not specified, the
4819ff03
LP
543 process is terminated right-away when
544 service stop is requested. Specifier
545 and environment variable substitution
546 is supported (including
4c42e8e1 547 <varname>$MAINPID</varname>, see
420a0166 548 above).</para></listitem>
0d624a78
LP
549 </varlistentry>
550
551 <varlistentry>
552 <term><varname>ExecStopPost=</varname></term>
553 <listitem><para>Additional commands
554 that are executed after the service
3ae390ba
MB
555 was stopped. This includes cases where
556 the commands configured in
557 <varname>ExecStop=</varname> were used,
6b4991cf 558 where the service does not have any
3ae390ba
MB
559 <varname>ExecStop=</varname> defined, or
560 where the service exited unexpectedly. This
b3eaa628 561 argument takes multiple command lines,
2480f0c6
ZJS
562 following the same scheme as described
563 for <varname>ExecStart</varname>. Use
b3eaa628 564 of these settings is
420a0166
LP
565 optional. Specifier and environment
566 variable substitution is
567 supported.</para></listitem>
0d624a78
LP
568 </varlistentry>
569
570 <varlistentry>
571 <term><varname>RestartSec=</varname></term>
572 <listitem><para>Configures the time to
573 sleep before restarting a service (as
574 configured with
575 <varname>Restart=</varname>). Takes a
576 unit-less value in seconds, or a time
577 span value such as "5min
578 20s". Defaults to
579 100ms.</para></listitem>
580 </varlistentry>
581
582 <varlistentry>
d568a335 583 <term><varname>TimeoutStartSec=</varname></term>
0d624a78 584 <listitem><para>Configures the time to
d568a335 585 wait for start-up. If a
0d624a78
LP
586 daemon service does not signal
587 start-up completion within the
d568a335 588 configured time, the service will be
0d624a78 589 considered failed and be shut down
d568a335
MS
590 again.
591 Takes a unit-less value in seconds, or a
592 time span value such as "5min
593 20s". Pass 0 to disable the timeout
63ba209d 594 logic. Defaults to <varname>TimeoutStartSec=</varname> from the
1f19a534 595 manager configuration file, except when
d568a335 596 <varname>Type=oneshot</varname> is
63ba209d 597 used, in which case the timeout
d568a335
MS
598 is disabled by default.
599 </para></listitem>
600 </varlistentry>
601
602 <varlistentry>
603 <term><varname>TimeoutStopSec=</varname></term>
604 <listitem><para>Configures the time to
605 wait for stop. If a service is asked
606 to stop but does not terminate in the
607 specified time, it will be terminated
05cc7267 608 forcibly via <constant>SIGTERM</constant>, and after
0d624a78 609 another delay of this time with
05cc7267 610 <constant>SIGKILL</constant> (See
62adf224 611 <varname>KillMode=</varname>
d568a335
MS
612 in <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
613 Takes a unit-less value in seconds, or a
0d624a78
LP
614 time span value such as "5min
615 20s". Pass 0 to disable the timeout
63ba209d 616 logic. Defaults to <varname>TimeoutStartSec=</varname> from the
1f19a534 617 manager configuration file.
d568a335
MS
618 </para></listitem>
619 </varlistentry>
620
621 <varlistentry>
622 <term><varname>TimeoutSec=</varname></term>
623 <listitem><para>A shorthand for configuring
624 both <varname>TimeoutStartSec=</varname>
625 and <varname>TimeoutStopSec=</varname>
626 to the specified value.
627 </para></listitem>
0d624a78
LP
628 </varlistentry>
629
bb242b7b
MO
630 <varlistentry>
631 <term><varname>WatchdogSec=</varname></term>
e8ab3ccb 632 <listitem><para>Configures the
a827e373
ZJS
633 watchdog timeout for a service. The
634 watchdog is activated when the start-up is
e8ab3ccb 635 completed. The service must call
bb242b7b 636 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>
dac051ad
LP
637 regularly with "WATCHDOG=1" (i.e. the
638 "keep-alive ping"). If the time
639 between two such calls is larger than
79640424 640 the configured time, then the service
dac051ad
LP
641 is placed in a failure state. By
642 setting <varname>Restart=</varname> to
643 <option>on-failure</option> or
79640424 644 <option>always</option>, the service
e8ab3ccb
LP
645 will be automatically restarted. The
646 time configured here will be passed to
647 the executed service process in the
648 <varname>WATCHDOG_USEC=</varname>
dac051ad
LP
649 environment variable. This allows
650 daemons to automatically enable the
651 keep-alive pinging logic if watchdog
652 support is enabled for the service. If
79640424 653 this option is used,
02c4ef9c
LP
654 <varname>NotifyAccess=</varname> (see
655 below) should be set to open access to
656 the notification socket provided by
657 systemd. If
dac051ad
LP
658 <varname>NotifyAccess=</varname> is
659 not set, it will be implicitly set to
02c4ef9c 660 <option>main</option>. Defaults to 0,
e8ab3ccb
LP
661 which disables this
662 feature.</para></listitem>
bb242b7b
MO
663 </varlistentry>
664
0d624a78
LP
665 <varlistentry>
666 <term><varname>Restart=</varname></term>
667 <listitem><para>Configures whether the
a827e373
ZJS
668 service shall be restarted when the
669 service process exits, is killed,
670 or a timeout is reached. The service
671 process may be the main service
672 process, but also one of the processes
673 specified with
674 <varname>ExecStartPre=</varname>,
675 <varname>ExecStartPost=</varname>,
676 <varname>ExecStopPre=</varname>,
677 <varname>ExecStopPost=</varname>, or
678 <varname>ExecReload=</varname>.
679 When the death of the process is a
680 result of systemd operation (e.g. service
681 stop or restart), the service will not be
682 restarted. Timeouts include missing
683 the watchdog "keep-alive ping"
684 deadline and a service start, reload,
685 and stop operation timeouts.</para>
686
687 <para>Takes one of
525ee6f4 688 <option>no</option>,
50caaedb
LP
689 <option>on-success</option>,
690 <option>on-failure</option>,
dc99a976 691 <option>on-watchdog</option>,
a827e373 692 <option>on-abort</option>, or
50caaedb 693 <option>always</option>. If set to
79640424 694 <option>no</option> (the default), the
a827e373 695 service will not be restarted. If set to
79640424 696 <option>on-success</option>, it will be
a827e373
ZJS
697 restarted only when the service process
698 exits cleanly.
699 In this context, a clean exit means
700 an exit code of 0, or one of the signals
05cc7267 701 <constant>SIGHUP</constant>, <constant>SIGINT</constant>, <constant>SIGTERM</constant>, or <constant>SIGPIPE</constant>, and
d2bbca68 702 additionally, exit statuses and signals
a827e373 703 specified in <varname>SuccessExitStatus=</varname>.
79640424 704 If set to <option>on-failure</option>,
a827e373
ZJS
705 the service will be restarted when the
706 process exits with an nonzero exit code,
707 is terminated by a signal (including on
5389fedd 708 core dump), when an operation (such as
a827e373
ZJS
709 service reload) times out, and when the
710 configured watchdog timeout is triggered.
711 If set to
79640424 712 <option>on-abort</option>, the service
a827e373
ZJS
713 will be restarted only if the service
714 process exits due to an uncaught
715 signal not specified as a clean exit
716 status.
717 If set to
79640424 718 <option>on-watchdog</option>, the service
dc99a976
HR
719 will be restarted only if the watchdog
720 timeout for the service expires.
721 If set to
79640424 722 <option>always</option>, the service
494a6682 723 will be restarted regardless of whether
5389fedd
LP
724 it exited cleanly or not, got
725 terminated abnormally by a signal or
a827e373
ZJS
726 hit a timeout.</para>
727
728 <para>In addition to the above settings,
729 the service will not be restarted if the
730 exit code or signal is specified in
731 <varname>RestartPreventExitStatus=</varname>
732 (see below).</para></listitem>
0d624a78
LP
733 </varlistentry>
734
96342de6 735 <varlistentry>
abdf7993
LP
736 <term><varname>SuccessExitStatus=</varname></term>
737 <listitem><para>Takes a list of exit
738 status definitions that when returned
739 by the main service process will be
740 considered successful termination, in
741 addition to the normal successful exit
05cc7267 742 code 0 and the signals <constant>SIGHUP</constant>, <constant>SIGINT</constant>,
a9a30533 743 <constant>SIGTERM</constant>, and <constant>SIGPIPE</constant>. Exit status
abdf7993 744 definitions can either be numeric exit
a827e373 745 codes or termination signal names,
29e254f7
DR
746 separated by spaces. Signals will only
747 be considered if the service does not implement
748 a signal handler and exits as a direct result
749 of receiving the signal. For example:
a9a30533
ZJS
750 <programlisting>SuccessExitStatus=1 2 8 <constant>SIGKILL</constant></programlisting>
751 ensures that exit codes 1, 2, 8 and
752 the termination signal
753 <constant>SIGKILL</constant> are
754 considered clean service terminations.
755 </para>
756
757 <para>Note that if a process has a
758 signal handler installed and exits by
759 calling
760 <citerefentry><refentrytitle>_exit</refentrytitle><manvolnum>2</manvolnum></citerefentry>
761 in response to a signal, the
762 information about the signal is lost.
763 Programs should instead perform cleanup and kill themselves with the same signal instead. See
764 <ulink url="http://www.cons.org/cracauer/sigint.html">Proper handling of SIGINT/SIGQUIT — How to be a proper program</ulink>.</para>
765
766 <para>This option may appear more than once
767 in which case the list of successful
768 exit statuses is merged. If the empty
769 string is assigned to this option, the
770 list is reset, all prior assignments
771 of this option will have no
772 effect.</para></listitem>
96342de6
LN
773 </varlistentry>
774
775 <varlistentry>
abdf7993
LP
776 <term><varname>RestartPreventExitStatus=</varname></term>
777 <listitem><para>Takes a list of exit
778 status definitions that when returned
779 by the main service process will
780 prevent automatic service restarts
781 regardless of the restart setting
782 configured with
783 <varname>Restart=</varname>. Exit
784 status definitions can either be
785 numeric exit codes or termination
786 signal names, and are separated by
787 spaces. Defaults to the empty list, so
788 that by default no exit status is
789 excluded from the configured restart
790 logic. Example:
909f413d
ZJS
791 <literal>RestartPreventExitStatus=1 6
792 SIGABRT</literal>, ensures that exit
74051b9b
LP
793 codes 1 and 6 and the termination
794 signal SIGABRT will not result in
795 automatic service restarting. This
796 option may appear more than once in
797 which case the list of restart preventing
798 statuses is merged. If the empty
79640424 799 string is assigned to this option, the
74051b9b
LP
800 list is reset, all prior assignments
801 of this option will have no
802 effect.</para></listitem>
96342de6
LN
803 </varlistentry>
804
0d624a78
LP
805 <varlistentry>
806 <term><varname>PermissionsStartOnly=</varname></term>
807 <listitem><para>Takes a boolean
808 argument. If true, the permission
809 related execution options as
810 configured with
811 <varname>User=</varname> and similar
812 options (see
813 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
814 for more information) are only applied
815 to the process started with
816 <varname>ExecStart=</varname>, and not
817 to the various other
818 <varname>ExecStartPre=</varname>,
819 <varname>ExecStartPost=</varname>,
820 <varname>ExecReload=</varname>,
821 <varname>ExecStop=</varname>,
822 <varname>ExecStopPost=</varname>
823 commands. If false, the setting is
824 applied to all configured commands the
825 same way. Defaults to
826 false.</para></listitem>
827 </varlistentry>
828
829 <varlistentry>
830 <term><varname>RootDirectoryStartOnly=</varname></term>
831 <listitem><para>Takes a boolean
832 argument. If true, the root directory
833 as configured with the
834 <varname>RootDirectory=</varname>
835 option (see
836 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
837 for more information) is only applied
838 to the process started with
839 <varname>ExecStart=</varname>, and not
840 to the various other
841 <varname>ExecStartPre=</varname>,
842 <varname>ExecStartPost=</varname>,
843 <varname>ExecReload=</varname>,
844 <varname>ExecStop=</varname>,
845 <varname>ExecStopPost=</varname>
846 commands. If false, the setting is
847 applied to all configured commands the
848 same way. Defaults to
849 false.</para></listitem>
850 </varlistentry>
851
0d624a78
LP
852 <varlistentry>
853 <term><varname>NonBlocking=</varname></term>
854 <listitem><para>Set O_NONBLOCK flag
855 for all file descriptors passed via
856 socket-based activation. If true, all
857 file descriptors >= 3 (i.e. all except
858 STDIN/STDOUT/STDERR) will have
859 the O_NONBLOCK flag set and hence are in
860 non-blocking mode. This option is only
861 useful in conjunction with a socket
862 unit, as described in
863 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>. Defaults
864 to false.</para></listitem>
865 </varlistentry>
866
867 <varlistentry>
868 <term><varname>NotifyAccess=</varname></term>
869 <listitem><para>Controls access to the
870 service status notification socket, as
871 accessible via the
872 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>
873 call. Takes one of
874 <option>none</option> (the default),
875 <option>main</option> or
876 <option>all</option>. If
79640424 877 <option>none</option>, no daemon status
f8553ccb 878 updates are accepted from the service
0d624a78 879 processes, all status update messages
79640424 880 are ignored. If <option>main</option>,
0d624a78
LP
881 only service updates sent from the
882 main process of the service are
79640424 883 accepted. If <option>all</option>, all
0d624a78
LP
884 services updates from all members of
885 the service's control group are
02c4ef9c 886 accepted. This option should be set to
0d624a78
LP
887 open access to the notification socket
888 when using
02c4ef9c 889 <varname>Type=notify</varname> or
28137202 890 <varname>WatchdogSec=</varname> (see
02c4ef9c 891 above). If those options are used but
79640424
JE
892 <varname>NotifyAccess=</varname> is not
893 configured, it will be implicitly set
02c4ef9c
LP
894 to
895 <option>main</option>.</para></listitem>
d1ab0ca0
LP
896 </varlistentry>
897
f72192c0
LP
898 <varlistentry>
899 <term><varname>Sockets=</varname></term>
900 <listitem><para>Specifies the name of
901 the socket units this service shall
902 inherit the sockets from when the
4f025f4c 903 service is started. Normally it
f72192c0
LP
904 should not be necessary to use this
905 setting as all sockets whose unit
906 shares the same name as the service
4f025f4c 907 (ignoring the different suffix of course)
f72192c0
LP
908 are passed to the spawned
909 process.</para>
910
911 <para>Note that the same socket may be
912 passed to multiple processes at the
913 same time. Also note that a different
914 service may be activated on incoming
915 traffic than inherits the sockets. Or
74051b9b 916 in other words: the
f72192c0
LP
917 <varname>Service=</varname> setting of
918 <filename>.socket</filename> units
6b4991cf 919 does not have to match the inverse of
74051b9b
LP
920 the <varname>Sockets=</varname>
921 setting of the
922 <filename>.service</filename> it
923 refers to.</para>
924
925 <para>This option may appear more than
926 once, in which case the list of socket
927 units is merged. If the empty string
79640424 928 is assigned to this option, the list of
74051b9b
LP
929 sockets is reset, all prior uses of
930 this setting will have no
931 effect.</para></listitem>
f72192c0
LP
932 </varlistentry>
933
092317d0
LP
934 <varlistentry>
935 <term><varname>StartLimitInterval=</varname></term>
936 <term><varname>StartLimitBurst=</varname></term>
937
938 <listitem><para>Configure service
79640424 939 start rate limiting. By default,
092317d0
LP
940 services which are started more often
941 than 5 times within 10s are not
942 permitted to start any more times
943 until the 10s interval ends. With
79640424 944 these two options, this rate limiting
092317d0
LP
945 may be modified. Use
946 <varname>StartLimitInterval=</varname>
3f41e1e5
LN
947 to configure the checking interval (defaults to
948 <varname>DefaultStartLimitInterval=</varname> in
949 manager configuration file, set to 0 to disable
092317d0
LP
950 any kind of rate limiting). Use
951 <varname>StartLimitBurst=</varname> to
952 configure how many starts per interval
3f41e1e5
LN
953 are allowed (defaults to
954 <varname>DefaultStartLimitBurst=</varname> in
955 manager configuration file). These
092317d0
LP
956 configuration options are particularly
957 useful in conjunction with
6ffd3337
LP
958 <varname>Restart=</varname>, however
959 apply to all kinds of starts
960 (including manual), not just those
961 triggered by the
962 <varname>Restart=</varname> logic.
963 Note that units which are configured
964 for <varname>Restart=</varname> and
965 which reach the start limit are not
f1c8f75b
LP
966 attempted to be restarted anymore,
967 however they may still be restarted
968 manually at a later point from which
969 point on the restart logic is again
451b34cc
LP
970 activated. Note that
971 <command>systemctl
972 reset-failed</command> will cause the
973 restart rate counter for a service to
974 be flushed, which is useful if the
975 administrator wants to manually start
976 a service and the start limit
977 interferes with
978 that.</para></listitem>
092317d0
LP
979 </varlistentry>
980
981 <varlistentry>
982 <term><varname>StartLimitAction=</varname></term>
983
984 <listitem><para>Configure the action
985 to take if the rate limit configured
986 with
987 <varname>StartLimitInterval=</varname>
988 and
989 <varname>StartLimitBurst=</varname> is
990 hit. Takes one of
991 <option>none</option>,
992 <option>reboot</option>,
993 <option>reboot-force</option> or
994 <option>reboot-immediate</option>. If
995 <option>none</option> is set,
996 hitting the rate limit will trigger no
997 action besides that the start will not
998 be
999 permitted. <option>reboot</option>
1000 causes a reboot following the normal
1001 shutdown procedure (i.e. equivalent to
1002 <command>systemctl reboot</command>),
1003 <option>reboot-force</option> causes
1004 an forced reboot which will terminate
1005 all processes forcibly but should
1006 cause no dirty file systems on reboot
1007 (i.e. equivalent to <command>systemctl
1008 reboot -f</command>) and
1009 <option>reboot-immediate</option>
1010 causes immediate execution of the
1011 <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry>
1012 system call, which might result in
1013 data loss. Defaults to
1014 <option>none</option>.</para></listitem>
1015 </varlistentry>
1016
d1ab0ca0 1017 </variablelist>
4819ff03
LP
1018
1019 <para>Check
1020 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
1021 and
1022 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>
1023 for more settings.</para>
1024
d1ab0ca0
LP
1025 </refsect1>
1026
c485d3ba
LP
1027 <refsect1>
1028 <title>Compatibility Options</title>
1029
1030 <para>The following options are also available in the
1031 <literal>[Service]</literal> section, but exist purely
1032 for compatibility reasons and should not be used in
1033 newly written service files.</para>
1034
ccc9a4f9 1035 <variablelist class='unit-directives'>
c485d3ba
LP
1036 <varlistentry>
1037 <term><varname>SysVStartPriority=</varname></term>
1038 <listitem><para>Set the SysV start
1039 priority to use to order this service
1040 in relation to SysV services lacking
1041 LSB headers. This option is only
1042 necessary to fix ordering in relation
1043 to legacy SysV services, that have no
1044 ordering information encoded in the
1045 script headers. As such it should only
1046 be used as temporary compatibility
1047 option, and not be used in new unit
1048 files. Almost always it is a better
1049 choice to add explicit ordering
1050 directives via
1051 <varname>After=</varname> or
1052 <varname>Before=</varname>,
1053 instead. For more details see
1054 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. If
1055 used, pass an integer value in the
1056 range 0-99.</para></listitem>
1057 </varlistentry>
1058
c485d3ba
LP
1059 </variablelist>
1060 </refsect1>
1061
d1ab0ca0
LP
1062 <refsect1>
1063 <title>See Also</title>
1064 <para>
f3e219a2 1065 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
0d624a78
LP
1066 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
1067 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
4819ff03 1068 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
3fde5f30 1069 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
9cc2c8b7
ZJS
1070 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1071 <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>
d1ab0ca0
LP
1072 </para>
1073 </refsect1>
1074
1075</refentry>