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