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