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