]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/systemd.service.xml
core: make sure to serialize jobs for all units
[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
bcddd5bf 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
bcddd5bf
JSJ
175 proceed with starting follow-up units
176 as soon as the parent process
0d624a78
LP
177 exits.</para>
178
c5315881 179 <para>Behavior of
34e9ba66 180 <option>oneshot</option> is similar
bcddd5bf 181 to <option>simple</option>; however,
0d624a78
LP
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
bcddd5bf 190 <option>simple</option>; however, it is
62adf224 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
bcddd5bf
JSJ
195 will proceed with starting follow-up
196 units 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 206 <option>notify</option> is similar to
bcddd5bf 207 <option>simple</option>; however, it is
0d624a78
LP
208 expected that the daemon sends a
209 notification message via
210 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>
bcddd5bf
JSJ
211 or an equivalent call when it has finished
212 starting up. systemd will proceed with
0d624a78
LP
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
bcddd5bf 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
bcddd5bf 263 file, the main PID is always known. The
3185a36b
LP
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
bcddd5bf 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
bcddd5bf
JSJ
300 is otherwise recommended if the process
301 takes a name on the D-Bus bus.</para>
d1ab0ca0
LP
302 </listitem>
303 </varlistentry>
304
305 <varlistentry>
306 <term><varname>ExecStart=</varname></term>
22f38abe
LP
307 <listitem><para>Commands with their
308 arguments that are executed when this
ec6039bc
ZJS
309 service is started. For each of the
310 specified commands, the first argument
311 must be an absolute and literal path
312 to an executable.</para>
2480f0c6 313
4c42e8e1
ZJS
314 <para>When <varname>Type</varname> is
315 not <option>oneshot</option>, only one
316 command may be given. When
b1690fe7 317 <varname>Type=oneshot</varname> is
2480f0c6
ZJS
318 used, more than one command may be
319 specified. Multiple command lines may
bcddd5bf 320 be concatenated in a single directive
2480f0c6
ZJS
321 by separating them with semicolons
322 (these semicolons must be passed as
323 separate words). Alternatively, this
324 directive may be specified more than
6baf995c 325 once with the same effect.
4c42e8e1 326 Lone semicolons may be escaped as
909f413d 327 <literal>\;</literal>. If the empty
79640424 328 string is assigned to this option, the
74051b9b
LP
329 list of commands to start is reset,
330 prior assignments of this option will
331 have no effect.</para>
2480f0c6 332
ec6039bc
ZJS
333 <para>Each command line is split on
334 whitespace, with the first item being
335 the command to execute, and the
336 subsequent items being the arguments.
337 Double quotes ("...") and single
338 quotes ('...') may be used, in which
339 case everything until the next
340 matching quote becomes part of the
341 same argument. Quotes themselves are
342 removed after parsing. In addition, a
343 trailing backslash
344 (<literal>\</literal>) may be used to
345 merge lines. This syntax is intended
346 to be very similar to shell syntax,
347 but only the meta-characters and
348 expansions described in the following
349 paragraphs are understood.
350 Specifically, redirection using
351 <literal>&lt;</literal>,
352 <literal>&lt;&lt;</literal>,
353 <literal>&gt;</literal>, and
354 <literal>&gt;&gt;</literal>, pipes
355 using <literal>|</literal>, and
356 running programs in the background
357 using <literal>&amp;</literal>
358 and <emphasis>other elements of shell
359 syntax are not supported</emphasis>.
360 </para>
361
4c42e8e1
ZJS
362 <para>If more than one command is
363 specified, the commands are invoked
bcddd5bf
JSJ
364 sequentially in the order they appear
365 in the unit file. If one of the
366 commands fails (and is not prefixed
367 with <literal>-</literal>), other lines
368 are not executed, and the unit is
369 considered failed.</para>
4c42e8e1 370
2480f0c6
ZJS
371 <para>Unless
372 <varname>Type=forking</varname> is
373 set, the process started via this
374 command line will be considered the
22f38abe
LP
375 main process of the daemon.</para>
376
377 <para>The command line accepts
909f413d 378 <literal>%</literal> specifiers as
22f38abe 379 described in
ec6039bc
ZJS
380 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
381 Note that the first argument of the
382 command line (i.e. the program to
383 execute) may not include
384 specifiers.</para>
b1690fe7 385
4c42e8e1
ZJS
386 <para>Basic environment variable
387 substitution is supported. Use
7734f773 388 <literal>${FOO}</literal> as part of a
bcddd5bf 389 word, or as a word of its own, on the
7734f773
BS
390 command line, in which case it will be
391 replaced by the value of the
392 environment variable including all
393 whitespace it contains, resulting in a
c5b37953 394 single argument. Use
7734f773
BS
395 <literal>$FOO</literal> as a separate
396 word on the command line, in which
397 case it will be replaced by the value
c5b37953
ZJS
398 of the environment variable split at
399 whitespace, resulting in zero or more
400 arguments. To pass a literal dollar
401 sign, use <literal>$$</literal>.
402 Variables whose value is not known at
403 expansion time are treated as empty
404 strings. Note that the first argument
405 (i.e. the program to execute) may not
406 be a variable.</para>
407
408 <para>Variables to be used in this
409 fashion may be defined through
410 <varname>Environment=</varname> and
411 <varname>EnvironmentFile=</varname>.
bcddd5bf 412 In addition, variables listed in the
c5b37953
ZJS
413 section "Environment variables in
414 spawned processes" in
bcddd5bf 415 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
c5b37953 416 which are considered "static
bcddd5bf 417 configuration", may be used (this includes
c5b37953
ZJS
418 e.g. <varname>$USER</varname>, but not
419 <varname>$TERM</varname>).</para>
a2927192 420
74051b9b
LP
421 <para>Optionally, if the absolute file
422 name is prefixed with
909f413d 423 <literal>@</literal>, the second token
74051b9b
LP
424 will be passed as
425 <literal>argv[0]</literal> to the
426 executed process, followed by the
427 further arguments specified. If the
e9dd9f95 428 absolute filename is prefixed with
79640424 429 <literal>-</literal>, an exit code of
74051b9b
LP
430 the command normally considered a
431 failure (i.e. non-zero exit status or
432 abnormal exit due to signal) is ignored
433 and considered success. If both
909f413d 434 <literal>-</literal> and
79640424 435 <literal>@</literal> are used, they
74051b9b
LP
436 can appear in either order.</para>
437
a2927192
LP
438 <para>Note that this setting does not
439 directly support shell command
440 lines. If shell command lines are to
79640424 441 be used, they need to be passed
a2927192 442 explicitly to a shell implementation
4c42e8e1 443 of some kind. Example:</para>
9fccdb0f 444 <programlisting>ExecStart=/bin/sh -c 'dmesg | tac'</programlisting>
ec6039bc 445 <para>Example:</para>
9fccdb0f 446 <programlisting>ExecStart=/bin/echo one ; /bin/echo "two two"</programlisting>
ec6039bc
ZJS
447 <para>This will execute
448 <command>/bin/echo</command> two
bcddd5bf 449 times, each time with one argument:
ec6039bc
ZJS
450 <literal>one</literal> and
451 <literal>two two</literal>,
bcddd5bf 452 respectively. Because two commands are
b040723e 453 specified,
ec6039bc
ZJS
454 <varname>Type=oneshot</varname> must
455 be used.</para>
456
457 <para>Example:</para>
458 <programlisting>ExecStart=/bin/echo / &gt;/dev/null &amp; \; \
9fccdb0f 459/bin/ls</programlisting>
ec6039bc
ZJS
460 <para>This will execute
461 <command>/bin/echo</command> with five
462 arguments: <literal>/</literal>,
463 <literal>&gt;/dev/null</literal>,
464 <literal>&amp;</literal>,
465 <literal>;</literal>, and
466 <literal>/bin/ls</literal>.</para>
467
468 <para>Example:</para>
469 <programlisting>Environment="ONE=one" 'TWO=two two'
9fccdb0f 470ExecStart=/bin/echo $ONE $TWO ${TWO}</programlisting>
ec6039bc
ZJS
471 <para>This will execute
472 <command>/bin/echo</command> with four
473 arguments: <literal>one</literal>,
474 <literal>two</literal>,
475 <literal>two</literal>, and
476 <literal>two two</literal>.</para>
477 </listitem>
0d624a78
LP
478 </varlistentry>
479
480 <varlistentry>
481 <term><varname>ExecStartPre=</varname></term>
482 <term><varname>ExecStartPost=</varname></term>
483 <listitem><para>Additional commands
16dad32e 484 that are executed before or after
0d624a78 485 the command in
2480f0c6
ZJS
486 <varname>ExecStart=</varname>, respectively.
487 Syntax is the same as for
488 <varname>ExecStart=</varname>, except
489 that multiple command lines are allowed
490 and the commands are executed one
491 after the other, serially.</para>
4c42e8e1
ZJS
492
493 <para>If any of those commands (not
909f413d 494 prefixed with <literal>-</literal>)
4c42e8e1
ZJS
495 fail, the rest are not executed and
496 the unit is considered failed.</para>
2480f0c6 497 </listitem>
0d624a78
LP
498 </varlistentry>
499
500 <varlistentry>
501 <term><varname>ExecReload=</varname></term>
502 <listitem><para>Commands to execute to
503 trigger a configuration reload in the
b3eaa628
LP
504 service. This argument takes multiple
505 command lines, following the same
2480f0c6
ZJS
506 scheme as described for
507 <varname>ExecStart=</varname>
b3eaa628 508 above. Use of this setting is
420a0166
LP
509 optional. Specifier and environment
510 variable substitution is supported
511 here following the same scheme as for
4c42e8e1
ZJS
512 <varname>ExecStart=</varname>.</para>
513
bcddd5bf
JSJ
514 <para>One additional, special
515 environment variable is set: if known,
4c42e8e1 516 <varname>$MAINPID</varname> is set to
97ae63e2
LP
517 the main process of the daemon, and
518 may be used for command lines like the
4c42e8e1
ZJS
519 following:</para>
520
521 <programlisting>/bin/kill -HUP $MAINPID</programlisting>
522 </listitem>
0d624a78
LP
523 </varlistentry>
524
525 <varlistentry>
526 <term><varname>ExecStop=</varname></term>
527 <listitem><para>Commands to execute to
528 stop the service started via
b3eaa628
LP
529 <varname>ExecStart=</varname>. This
530 argument takes multiple command lines,
2480f0c6
ZJS
531 following the same scheme as described
532 for <varname>ExecStart=</varname>
b3eaa628 533 above. Use of this setting is
bcddd5bf
JSJ
534 optional. After the commands configured
535 in this option are run, all processes
536 remaining for a service are
0d624a78
LP
537 terminated according to the
538 <varname>KillMode=</varname> setting
4819ff03
LP
539 (see
540 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>). If
79640424 541 this option is not specified, the
bcddd5bf 542 process is terminated immediately when
4819ff03
LP
543 service stop is requested. Specifier
544 and environment variable substitution
545 is supported (including
4c42e8e1 546 <varname>$MAINPID</varname>, see
420a0166 547 above).</para></listitem>
0d624a78
LP
548 </varlistentry>
549
550 <varlistentry>
551 <term><varname>ExecStopPost=</varname></term>
552 <listitem><para>Additional commands
553 that are executed after the service
3ae390ba
MB
554 was stopped. This includes cases where
555 the commands configured in
556 <varname>ExecStop=</varname> were used,
6b4991cf 557 where the service does not have any
3ae390ba
MB
558 <varname>ExecStop=</varname> defined, or
559 where the service exited unexpectedly. This
b3eaa628 560 argument takes multiple command lines,
2480f0c6
ZJS
561 following the same scheme as described
562 for <varname>ExecStart</varname>. Use
b3eaa628 563 of these settings is
420a0166
LP
564 optional. Specifier and environment
565 variable substitution is
566 supported.</para></listitem>
0d624a78
LP
567 </varlistentry>
568
569 <varlistentry>
570 <term><varname>RestartSec=</varname></term>
571 <listitem><para>Configures the time to
572 sleep before restarting a service (as
573 configured with
574 <varname>Restart=</varname>). Takes a
575 unit-less value in seconds, or a time
576 span value such as "5min
577 20s". Defaults to
578 100ms.</para></listitem>
579 </varlistentry>
580
581 <varlistentry>
d568a335 582 <term><varname>TimeoutStartSec=</varname></term>
0d624a78 583 <listitem><para>Configures the time to
d568a335 584 wait for start-up. If a
0d624a78
LP
585 daemon service does not signal
586 start-up completion within the
d568a335 587 configured time, the service will be
bcddd5bf
JSJ
588 considered failed and will be shut
589 down again.
d568a335
MS
590 Takes a unit-less value in seconds, or a
591 time span value such as "5min
bcddd5bf
JSJ
592 20s". Pass <literal>0</literal> to
593 disable the timeout logic. Defaults to
594 <varname>TimeoutStartSec=</varname> from
595 the manager configuration file, except
596 when <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
bcddd5bf 606 to stop, but does not terminate in the
d568a335 607 specified time, it will be terminated
bcddd5bf
JSJ
608 forcibly via <constant>SIGTERM</constant>,
609 and after another timeout of equal duration
610 with <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 614 time span value such as "5min
bcddd5bf
JSJ
615 20s". Pass <literal>0</literal> to disable
616 the timeout logic. Defaults to
617 <varname>TimeoutStartSec=</varname> from the
1f19a534 618 manager configuration file.
d568a335
MS
619 </para></listitem>
620 </varlistentry>
621
622 <varlistentry>
623 <term><varname>TimeoutSec=</varname></term>
624 <listitem><para>A shorthand for configuring
625 both <varname>TimeoutStartSec=</varname>
626 and <varname>TimeoutStopSec=</varname>
627 to the specified value.
628 </para></listitem>
0d624a78
LP
629 </varlistentry>
630
bb242b7b
MO
631 <varlistentry>
632 <term><varname>WatchdogSec=</varname></term>
e8ab3ccb 633 <listitem><para>Configures the
a827e373
ZJS
634 watchdog timeout for a service. The
635 watchdog is activated when the start-up is
e8ab3ccb 636 completed. The service must call
bb242b7b 637 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>
bcddd5bf
JSJ
638 regularly with <literal>WATCHDOG=1</literal>
639 (i.e. the "keep-alive ping"). If the time
dac051ad 640 between two such calls is larger than
79640424 641 the configured time, then the service
bcddd5bf 642 is placed in a failed state. By
dac051ad
LP
643 setting <varname>Restart=</varname> to
644 <option>on-failure</option> or
79640424 645 <option>always</option>, the service
e8ab3ccb
LP
646 will be automatically restarted. The
647 time configured here will be passed to
648 the executed service process in the
649 <varname>WATCHDOG_USEC=</varname>
dac051ad
LP
650 environment variable. This allows
651 daemons to automatically enable the
652 keep-alive pinging logic if watchdog
653 support is enabled for the service. If
79640424 654 this option is used,
02c4ef9c
LP
655 <varname>NotifyAccess=</varname> (see
656 below) should be set to open access to
657 the notification socket provided by
658 systemd. If
dac051ad
LP
659 <varname>NotifyAccess=</varname> is
660 not set, it will be implicitly set to
02c4ef9c 661 <option>main</option>. Defaults to 0,
e8ab3ccb
LP
662 which disables this
663 feature.</para></listitem>
bb242b7b
MO
664 </varlistentry>
665
0d624a78
LP
666 <varlistentry>
667 <term><varname>Restart=</varname></term>
668 <listitem><para>Configures whether the
a827e373
ZJS
669 service shall be restarted when the
670 service process exits, is killed,
671 or a timeout is reached. The service
672 process may be the main service
bcddd5bf
JSJ
673 process, but it may also be one of the
674 processes specified with
a827e373
ZJS
675 <varname>ExecStartPre=</varname>,
676 <varname>ExecStartPost=</varname>,
c32acc96 677 <varname>ExecStop=</varname>,
a827e373
ZJS
678 <varname>ExecStopPost=</varname>, or
679 <varname>ExecReload=</varname>.
680 When the death of the process is a
681 result of systemd operation (e.g. service
682 stop or restart), the service will not be
683 restarted. Timeouts include missing
684 the watchdog "keep-alive ping"
685 deadline and a service start, reload,
686 and stop operation timeouts.</para>
687
688 <para>Takes one of
525ee6f4 689 <option>no</option>,
50caaedb
LP
690 <option>on-success</option>,
691 <option>on-failure</option>,
dc99a976 692 <option>on-watchdog</option>,
a827e373 693 <option>on-abort</option>, or
50caaedb 694 <option>always</option>. If set to
79640424 695 <option>no</option> (the default), the
a827e373 696 service will not be restarted. If set to
79640424 697 <option>on-success</option>, it will be
a827e373
ZJS
698 restarted only when the service process
699 exits cleanly.
700 In this context, a clean exit means
701 an exit code of 0, or one of the signals
bcddd5bf
JSJ
702 <constant>SIGHUP</constant>,
703 <constant>SIGINT</constant>,
704 <constant>SIGTERM</constant>,
705 or <constant>SIGPIPE</constant>, and
d2bbca68 706 additionally, exit statuses and signals
a827e373 707 specified in <varname>SuccessExitStatus=</varname>.
79640424 708 If set to <option>on-failure</option>,
a827e373 709 the service will be restarted when the
bcddd5bf 710 process exits with a non-zero exit code,
a827e373 711 is terminated by a signal (including on
5389fedd 712 core dump), when an operation (such as
a827e373
ZJS
713 service reload) times out, and when the
714 configured watchdog timeout is triggered.
715 If set to
79640424 716 <option>on-abort</option>, the service
a827e373
ZJS
717 will be restarted only if the service
718 process exits due to an uncaught
719 signal not specified as a clean exit
720 status.
721 If set to
79640424 722 <option>on-watchdog</option>, the service
dc99a976
HR
723 will be restarted only if the watchdog
724 timeout for the service expires.
725 If set to
79640424 726 <option>always</option>, the service
494a6682 727 will be restarted regardless of whether
5389fedd 728 it exited cleanly or not, got
bcddd5bf 729 terminated abnormally by a signal, or
a827e373
ZJS
730 hit a timeout.</para>
731
732 <para>In addition to the above settings,
733 the service will not be restarted if the
734 exit code or signal is specified in
735 <varname>RestartPreventExitStatus=</varname>
736 (see below).</para></listitem>
0d624a78
LP
737 </varlistentry>
738
96342de6 739 <varlistentry>
abdf7993
LP
740 <term><varname>SuccessExitStatus=</varname></term>
741 <listitem><para>Takes a list of exit
742 status definitions that when returned
743 by the main service process will be
744 considered successful termination, in
745 addition to the normal successful exit
05cc7267 746 code 0 and the signals <constant>SIGHUP</constant>, <constant>SIGINT</constant>,
a9a30533 747 <constant>SIGTERM</constant>, and <constant>SIGPIPE</constant>. Exit status
abdf7993 748 definitions can either be numeric exit
a827e373 749 codes or termination signal names,
4a3fa6ac 750 separated by spaces. For example:
73e231ab
JE
751 <programlisting>SuccessExitStatus=1 2 8 <constant>SIGKILL</constant></programlisting>
752 ensures that exit codes 1, 2, 8 and
753 the termination signal
754 <constant>SIGKILL</constant> are
755 considered clean service terminations.
756 </para>
757
758 <para>Note that if a process has a
759 signal handler installed and exits by
760 calling
761 <citerefentry><refentrytitle>_exit</refentrytitle><manvolnum>2</manvolnum></citerefentry>
762 in response to a signal, the
763 information about the signal is lost.
764 Programs should instead perform cleanup and kill themselves with the same signal instead. See
765 <ulink url="http://www.cons.org/cracauer/sigint.html">Proper handling of SIGINT/SIGQUIT — How to be a proper program</ulink>.</para>
766
767 <para>This option may appear more than once,
768 in which case the list of successful
769 exit statuses is merged. If the empty
770 string is assigned to this option, the
771 list is reset, all prior assignments
772 of this option will have no
773 effect.</para></listitem>
96342de6
LN
774 </varlistentry>
775
776 <varlistentry>
abdf7993
LP
777 <term><varname>RestartPreventExitStatus=</varname></term>
778 <listitem><para>Takes a list of exit
779 status definitions that when returned
780 by the main service process will
bcddd5bf 781 prevent automatic service restarts,
abdf7993
LP
782 regardless of the restart setting
783 configured with
784 <varname>Restart=</varname>. Exit
785 status definitions can either be
786 numeric exit codes or termination
787 signal names, and are separated by
788 spaces. Defaults to the empty list, so
bcddd5bf 789 that, by default, no exit status is
abdf7993
LP
790 excluded from the configured restart
791 logic. Example:
909f413d
ZJS
792 <literal>RestartPreventExitStatus=1 6
793 SIGABRT</literal>, ensures that exit
74051b9b 794 codes 1 and 6 and the termination
bcddd5bf
JSJ
795 signal <constant>SIGABRT</constant> will
796 not result in automatic service
797 restarting. This
798 option may appear more than once, in
799 which case the list of restart-preventing
74051b9b 800 statuses is merged. If the empty
79640424 801 string is assigned to this option, the
bcddd5bf 802 list is reset and all prior assignments
74051b9b
LP
803 of this option will have no
804 effect.</para></listitem>
96342de6
LN
805 </varlistentry>
806
0d624a78
LP
807 <varlistentry>
808 <term><varname>PermissionsStartOnly=</varname></term>
809 <listitem><para>Takes a boolean
bcddd5bf
JSJ
810 argument. If true, the permission-related
811 execution options, as
0d624a78
LP
812 configured with
813 <varname>User=</varname> and similar
814 options (see
815 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
bcddd5bf 816 for more information), are only applied
0d624a78
LP
817 to the process started with
818 <varname>ExecStart=</varname>, and not
819 to the various other
820 <varname>ExecStartPre=</varname>,
821 <varname>ExecStartPost=</varname>,
822 <varname>ExecReload=</varname>,
bcddd5bf 823 <varname>ExecStop=</varname>, and
0d624a78
LP
824 <varname>ExecStopPost=</varname>
825 commands. If false, the setting is
826 applied to all configured commands the
827 same way. Defaults to
828 false.</para></listitem>
829 </varlistentry>
830
831 <varlistentry>
832 <term><varname>RootDirectoryStartOnly=</varname></term>
833 <listitem><para>Takes a boolean
bcddd5bf 834 argument. If true, the root directory,
0d624a78
LP
835 as configured with the
836 <varname>RootDirectory=</varname>
837 option (see
838 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
bcddd5bf 839 for more information), is only applied
0d624a78
LP
840 to the process started with
841 <varname>ExecStart=</varname>, and not
842 to the various other
843 <varname>ExecStartPre=</varname>,
844 <varname>ExecStartPost=</varname>,
845 <varname>ExecReload=</varname>,
bcddd5bf 846 <varname>ExecStop=</varname>, and
0d624a78
LP
847 <varname>ExecStopPost=</varname>
848 commands. If false, the setting is
849 applied to all configured commands the
850 same way. Defaults to
851 false.</para></listitem>
852 </varlistentry>
853
0d624a78
LP
854 <varlistentry>
855 <term><varname>NonBlocking=</varname></term>
bcddd5bf
JSJ
856 <listitem><para>Set the
857 <constant>O_NONBLOCK</constant> flag
0d624a78
LP
858 for all file descriptors passed via
859 socket-based activation. If true, all
860 file descriptors >= 3 (i.e. all except
6db27428 861 stdin, stdout, and stderr) will have
bcddd5bf
JSJ
862 the <constant>O_NONBLOCK</constant> flag
863 set and hence are in
0d624a78
LP
864 non-blocking mode. This option is only
865 useful in conjunction with a socket
866 unit, as described in
867 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>. Defaults
868 to false.</para></listitem>
869 </varlistentry>
870
871 <varlistentry>
872 <term><varname>NotifyAccess=</varname></term>
873 <listitem><para>Controls access to the
874 service status notification socket, as
875 accessible via the
876 <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry>
877 call. Takes one of
878 <option>none</option> (the default),
879 <option>main</option> or
880 <option>all</option>. If
79640424 881 <option>none</option>, no daemon status
f8553ccb 882 updates are accepted from the service
0d624a78 883 processes, all status update messages
79640424 884 are ignored. If <option>main</option>,
0d624a78
LP
885 only service updates sent from the
886 main process of the service are
79640424 887 accepted. If <option>all</option>, all
0d624a78
LP
888 services updates from all members of
889 the service's control group are
02c4ef9c 890 accepted. This option should be set to
0d624a78
LP
891 open access to the notification socket
892 when using
02c4ef9c 893 <varname>Type=notify</varname> or
28137202 894 <varname>WatchdogSec=</varname> (see
02c4ef9c 895 above). If those options are used but
79640424
JE
896 <varname>NotifyAccess=</varname> is not
897 configured, it will be implicitly set
02c4ef9c
LP
898 to
899 <option>main</option>.</para></listitem>
d1ab0ca0
LP
900 </varlistentry>
901
f72192c0
LP
902 <varlistentry>
903 <term><varname>Sockets=</varname></term>
904 <listitem><para>Specifies the name of
905 the socket units this service shall
906 inherit the sockets from when the
4f025f4c 907 service is started. Normally it
f72192c0
LP
908 should not be necessary to use this
909 setting as all sockets whose unit
910 shares the same name as the service
4f025f4c 911 (ignoring the different suffix of course)
f72192c0
LP
912 are passed to the spawned
913 process.</para>
914
915 <para>Note that the same socket may be
916 passed to multiple processes at the
917 same time. Also note that a different
918 service may be activated on incoming
bcddd5bf
JSJ
919 traffic than that which inherits the
920 sockets. Or in other words: the
f72192c0
LP
921 <varname>Service=</varname> setting of
922 <filename>.socket</filename> units
6b4991cf 923 does not have to match the inverse of
74051b9b
LP
924 the <varname>Sockets=</varname>
925 setting of the
926 <filename>.service</filename> it
927 refers to.</para>
928
929 <para>This option may appear more than
930 once, in which case the list of socket
931 units is merged. If the empty string
79640424 932 is assigned to this option, the list of
bcddd5bf 933 sockets is reset, and all prior uses of
74051b9b
LP
934 this setting will have no
935 effect.</para></listitem>
f72192c0
LP
936 </varlistentry>
937
092317d0
LP
938 <varlistentry>
939 <term><varname>StartLimitInterval=</varname></term>
940 <term><varname>StartLimitBurst=</varname></term>
941
942 <listitem><para>Configure service
79640424 943 start rate limiting. By default,
bcddd5bf
JSJ
944 services which are started more
945 than 5 times within 10 seconds are not
092317d0 946 permitted to start any more times
bcddd5bf 947 until the 10 second interval ends. With
79640424 948 these two options, this rate limiting
092317d0
LP
949 may be modified. Use
950 <varname>StartLimitInterval=</varname>
3f41e1e5
LN
951 to configure the checking interval (defaults to
952 <varname>DefaultStartLimitInterval=</varname> in
953 manager configuration file, set to 0 to disable
092317d0
LP
954 any kind of rate limiting). Use
955 <varname>StartLimitBurst=</varname> to
956 configure how many starts per interval
3f41e1e5
LN
957 are allowed (defaults to
958 <varname>DefaultStartLimitBurst=</varname> in
959 manager configuration file). These
092317d0
LP
960 configuration options are particularly
961 useful in conjunction with
bcddd5bf
JSJ
962 <varname>Restart=</varname>; however,
963 they apply to all kinds of starts
6ffd3337
LP
964 (including manual), not just those
965 triggered by the
966 <varname>Restart=</varname> logic.
967 Note that units which are configured
968 for <varname>Restart=</varname> and
969 which reach the start limit are not
bcddd5bf
JSJ
970 attempted to be restarted anymore;
971 however, they may still be restarted
972 manually at a later point, from which
973 point on, the restart logic is again
451b34cc
LP
974 activated. Note that
975 <command>systemctl
976 reset-failed</command> will cause the
977 restart rate counter for a service to
978 be flushed, which is useful if the
979 administrator wants to manually start
980 a service and the start limit
981 interferes with
982 that.</para></listitem>
092317d0
LP
983 </varlistentry>
984
985 <varlistentry>
986 <term><varname>StartLimitAction=</varname></term>
987
988 <listitem><para>Configure the action
989 to take if the rate limit configured
990 with
991 <varname>StartLimitInterval=</varname>
992 and
993 <varname>StartLimitBurst=</varname> is
994 hit. Takes one of
995 <option>none</option>,
996 <option>reboot</option>,
bcddd5bf 997 <option>reboot-force</option>, or
092317d0
LP
998 <option>reboot-immediate</option>. If
999 <option>none</option> is set,
1000 hitting the rate limit will trigger no
1001 action besides that the start will not
bcddd5bf 1002 be permitted. <option>reboot</option>
092317d0
LP
1003 causes a reboot following the normal
1004 shutdown procedure (i.e. equivalent to
bcddd5bf 1005 <command>systemctl reboot</command>).
092317d0 1006 <option>reboot-force</option> causes
bcddd5bf 1007 a forced reboot which will terminate
092317d0
LP
1008 all processes forcibly but should
1009 cause no dirty file systems on reboot
1010 (i.e. equivalent to <command>systemctl
1011 reboot -f</command>) and
1012 <option>reboot-immediate</option>
1013 causes immediate execution of the
1014 <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry>
1015 system call, which might result in
bcddd5bf 1016 data loss. Defaults to
092317d0
LP
1017 <option>none</option>.</para></listitem>
1018 </varlistentry>
1019
efe6e7d3
MO
1020 <varlistentry>
1021 <term><varname>RebootArgument=</varname></term>
1022 <listitem><para>Configure the optional
1023 argument for the
1024 <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry>
1025 system call if
1026 <varname>StartLimitAction=</varname>
1027 is a reboot action. This works just
1028 like the optional argument to
1029 <command>systemctl reboot</command>
1030 command.</para></listitem>
1031 </varlistentry>
1032
93ae25e6
MO
1033 <varlistentry>
1034 <term><varname>FailureAction=</varname></term>
1035 <listitem><para>Configure the action
1036 to take when the service enters a failed
1037 state. Takes the same values as
1038 <varname>StartLimitAction=</varname>
1039 and executes the same actions.
1040 Defaults to <option>none</option>.
1041 </para></listitem>
1042 </varlistentry>
1043
d1ab0ca0 1044 </variablelist>
4819ff03
LP
1045
1046 <para>Check
1047 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
1048 and
1049 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>
1050 for more settings.</para>
1051
d1ab0ca0
LP
1052 </refsect1>
1053
c485d3ba
LP
1054 <refsect1>
1055 <title>Compatibility Options</title>
1056
1057 <para>The following options are also available in the
1058 <literal>[Service]</literal> section, but exist purely
1059 for compatibility reasons and should not be used in
1060 newly written service files.</para>
1061
ccc9a4f9 1062 <variablelist class='unit-directives'>
c485d3ba
LP
1063 <varlistentry>
1064 <term><varname>SysVStartPriority=</varname></term>
1065 <listitem><para>Set the SysV start
1066 priority to use to order this service
1067 in relation to SysV services lacking
1068 LSB headers. This option is only
1069 necessary to fix ordering in relation
bcddd5bf 1070 to legacy SysV services that have no
c485d3ba 1071 ordering information encoded in the
bcddd5bf
JSJ
1072 script headers. As such, it should only
1073 be used as a temporary compatibility
1074 option and should not be used in new unit
1075 files. Almost always, it is a better
c485d3ba
LP
1076 choice to add explicit ordering
1077 directives via
1078 <varname>After=</varname> or
1079 <varname>Before=</varname>,
bcddd5bf
JSJ
1080 instead. For more details, see
1081 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
1082 If used, pass an integer value in the
c485d3ba
LP
1083 range 0-99.</para></listitem>
1084 </varlistentry>
c485d3ba
LP
1085 </variablelist>
1086 </refsect1>
1087
d1ab0ca0
LP
1088 <refsect1>
1089 <title>See Also</title>
1090 <para>
f3e219a2 1091 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
0d624a78
LP
1092 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
1093 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
4819ff03 1094 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
3fde5f30 1095 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
9cc2c8b7
ZJS
1096 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
1097 <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>
d1ab0ca0
LP
1098 </para>
1099 </refsect1>
1100
1101</refentry>