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