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