]>
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 | |
103 | incomptibilities see the <ulink | |
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 | |
163 | process. This is the behaviour of | |
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 | ||
174 | <para>Behaviour 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 | ||
183 | <para>Behaviour of | |
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 LP |
199 | |
200 | <para>Behaviour of | |
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 LP |
218 | |
219 | <para>Behaviour of | |
220 | <option>idle</option> is very similar | |
349b915d | 221 | to <option>simple</option>, however |
a8ad0f89 LP |
222 | actual execution of a the service |
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 | |
248 | should if it cannot be determined | |
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 | |
286 | name, where this service is reachable | |
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> | |
0d624a78 LP |
299 | <listitem><para>Takes a command line |
300 | that is executed when this service | |
301 | shall be started up. The first token | |
302 | of the command line must be an | |
303 | absolute file name, then followed by | |
304 | arguments for the process. It is | |
305 | mandatory to set this option for all | |
306 | services. This option may not be | |
b1690fe7 LP |
307 | specified more than once, except when |
308 | <varname>Type=oneshot</varname> is | |
309 | used in which case more than one | |
310 | <varname>ExecStart=</varname> line is | |
311 | accepted which are then invoked one by | |
312 | one, sequentially in the order they | |
313 | appear in the unit file.</para> | |
314 | ||
315 | <para>Optionally, if the absolute file | |
316 | name is prefixed with | |
317 | <literal>@</literal>, the second token | |
318 | will be passed as | |
62adf224 LP |
319 | <literal>argv[0]</literal> to the |
320 | executed process, followed by the | |
b708e7ce LP |
321 | further arguments specified. If the |
322 | first token is prefixed with | |
b1690fe7 | 323 | <literal>-</literal> an exit code of |
b708e7ce | 324 | the command normally considered a |
b1690fe7 | 325 | failure (i.e. non-zero exit status or |
5471472d | 326 | abnormal exit due to signal) is ignored |
b1690fe7 LP |
327 | and considered success. If both |
328 | <literal>-</literal> and | |
329 | <literal>@</literal> are used for the | |
5471472d | 330 | same command the former must precede |
b1690fe7 | 331 | the latter. Unless |
420a0166 LP |
332 | <varname>Type=forking</varname> is |
333 | set, the process started via this | |
334 | command line will be considered the | |
335 | main process of the daemon. The | |
336 | command line accepts % specifiers as | |
337 | described in | |
7734f773 BS |
338 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para> |
339 | ||
340 | <para>On top of that basic environment | |
341 | variable substitution is | |
342 | supported. Use | |
343 | <literal>${FOO}</literal> as part of a | |
344 | word, or as word of its own on the | |
345 | command line, in which case it will be | |
346 | replaced by the value of the | |
347 | environment variable including all | |
348 | whitespace it contains, resulting in a | |
349 | single argument. Use | |
350 | <literal>$FOO</literal> as a separate | |
351 | word on the command line, in which | |
352 | case it will be replaced by the value | |
353 | of the environment variable split up | |
354 | at whitespace, resulting in no or more | |
355 | arguments. Note that the first | |
356 | argument (i.e. the program to execute) | |
357 | may not be a variable, and must be a | |
358 | literal and absolute path | |
359 | name.</para></listitem> | |
0d624a78 LP |
360 | </varlistentry> |
361 | ||
362 | <varlistentry> | |
363 | <term><varname>ExecStartPre=</varname></term> | |
364 | <term><varname>ExecStartPost=</varname></term> | |
365 | <listitem><para>Additional commands | |
366 | that are executed before (resp. after) | |
367 | the command in | |
b3eaa628 LP |
368 | <varname>ExecStart=</varname>. Multiple |
369 | command lines may be concatenated in a | |
c899f8c6 | 370 | single directive, by separating them |
b3eaa628 | 371 | by semicolons (these semicolons must |
96d4ce01 | 372 | be passed as separate words). In that |
b3eaa628 LP |
373 | case, the commands are executed one |
374 | after the other, | |
375 | serially. Alternatively, these | |
376 | directives may be specified more than | |
5471472d | 377 | once with the same effect. However, |
b3eaa628 LP |
378 | the latter syntax is not recommended |
379 | for compatibility with parsers | |
380 | suitable for XDG | |
381 | <filename>.desktop</filename> files. | |
382 | Use of these settings is | |
420a0166 LP |
383 | optional. Specifier and environment |
384 | variable substitution is | |
385 | supported.</para></listitem> | |
0d624a78 LP |
386 | </varlistentry> |
387 | ||
388 | <varlistentry> | |
389 | <term><varname>ExecReload=</varname></term> | |
390 | <listitem><para>Commands to execute to | |
391 | trigger a configuration reload in the | |
b3eaa628 LP |
392 | service. This argument takes multiple |
393 | command lines, following the same | |
394 | scheme as pointed out for | |
395 | <varname>ExecStartPre=</varname> | |
396 | above. Use of this setting is | |
420a0166 LP |
397 | optional. Specifier and environment |
398 | variable substitution is supported | |
399 | here following the same scheme as for | |
400 | <varname>ExecStart=</varname>. One | |
401 | special environment variable is set: | |
402 | if known <literal>$MAINPID</literal> is | |
403 | set to the main process of the | |
404 | daemon, and may be used for command | |
405 | lines like the following: | |
406 | <command>/bin/kill -HUP | |
075b1e86 | 407 | $MAINPID</command>.</para></listitem> |
0d624a78 LP |
408 | </varlistentry> |
409 | ||
410 | <varlistentry> | |
411 | <term><varname>ExecStop=</varname></term> | |
412 | <listitem><para>Commands to execute to | |
413 | stop the service started via | |
b3eaa628 LP |
414 | <varname>ExecStart=</varname>. This |
415 | argument takes multiple command lines, | |
416 | following the same scheme as pointed | |
417 | out for | |
418 | <varname>ExecStartPre=</varname> | |
419 | above. Use of this setting is | |
0d624a78 LP |
420 | optional. All processes remaining for |
421 | a service after the commands | |
422 | configured in this option are run are | |
423 | terminated according to the | |
424 | <varname>KillMode=</varname> setting | |
4819ff03 LP |
425 | (see |
426 | <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>). If | |
427 | this option is not specified the | |
428 | process is terminated right-away when | |
429 | service stop is requested. Specifier | |
430 | and environment variable substitution | |
431 | is supported (including | |
075b1e86 | 432 | <literal>$MAINPID</literal>, see |
420a0166 | 433 | above).</para></listitem> |
0d624a78 LP |
434 | </varlistentry> |
435 | ||
436 | <varlistentry> | |
437 | <term><varname>ExecStopPost=</varname></term> | |
438 | <listitem><para>Additional commands | |
439 | that are executed after the service | |
440 | was stopped using the commands | |
441 | configured in | |
b3eaa628 LP |
442 | <varname>ExecStop=</varname>. This |
443 | argument takes multiple command lines, | |
444 | following the same scheme as pointed | |
445 | out for | |
446 | <varname>ExecStartPre</varname>. Use | |
447 | of these settings is | |
420a0166 LP |
448 | optional. Specifier and environment |
449 | variable substitution is | |
450 | supported.</para></listitem> | |
0d624a78 LP |
451 | </varlistentry> |
452 | ||
453 | <varlistentry> | |
454 | <term><varname>RestartSec=</varname></term> | |
455 | <listitem><para>Configures the time to | |
456 | sleep before restarting a service (as | |
457 | configured with | |
458 | <varname>Restart=</varname>). Takes a | |
459 | unit-less value in seconds, or a time | |
460 | span value such as "5min | |
461 | 20s". Defaults to | |
462 | 100ms.</para></listitem> | |
463 | </varlistentry> | |
464 | ||
465 | <varlistentry> | |
d568a335 | 466 | <term><varname>TimeoutStartSec=</varname></term> |
0d624a78 | 467 | <listitem><para>Configures the time to |
d568a335 | 468 | wait for start-up. If a |
0d624a78 LP |
469 | daemon service does not signal |
470 | start-up completion within the | |
d568a335 | 471 | configured time, the service will be |
0d624a78 | 472 | considered failed and be shut down |
d568a335 MS |
473 | again. |
474 | Takes a unit-less value in seconds, or a | |
475 | time span value such as "5min | |
476 | 20s". Pass 0 to disable the timeout | |
477 | logic. Defaults to 90s, except when | |
478 | <varname>Type=oneshot</varname> is | |
479 | used in which case the timeout | |
480 | is disabled by default. | |
481 | </para></listitem> | |
482 | </varlistentry> | |
483 | ||
484 | <varlistentry> | |
485 | <term><varname>TimeoutStopSec=</varname></term> | |
486 | <listitem><para>Configures the time to | |
487 | wait for stop. If a service is asked | |
488 | to stop but does not terminate in the | |
489 | specified time, it will be terminated | |
0d624a78 LP |
490 | forcibly via SIGTERM, and after |
491 | another delay of this time with | |
d568a335 | 492 | SIGKILL (See |
62adf224 | 493 | <varname>KillMode=</varname> |
d568a335 MS |
494 | in <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>). |
495 | Takes a unit-less value in seconds, or a | |
0d624a78 LP |
496 | time span value such as "5min |
497 | 20s". Pass 0 to disable the timeout | |
d568a335 MS |
498 | logic. Defaults to 90s. |
499 | </para></listitem> | |
500 | </varlistentry> | |
501 | ||
502 | <varlistentry> | |
503 | <term><varname>TimeoutSec=</varname></term> | |
504 | <listitem><para>A shorthand for configuring | |
505 | both <varname>TimeoutStartSec=</varname> | |
506 | and <varname>TimeoutStopSec=</varname> | |
507 | to the specified value. | |
508 | </para></listitem> | |
0d624a78 LP |
509 | </varlistentry> |
510 | ||
bb242b7b MO |
511 | <varlistentry> |
512 | <term><varname>WatchdogSec=</varname></term> | |
e8ab3ccb LP |
513 | <listitem><para>Configures the |
514 | watchdog timeout for a service. This | |
515 | is activated when the start-up is | |
516 | completed. The service must call | |
bb242b7b | 517 | <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry> |
dac051ad LP |
518 | regularly with "WATCHDOG=1" (i.e. the |
519 | "keep-alive ping"). If the time | |
520 | between two such calls is larger than | |
521 | the configured time then the service | |
522 | is placed in a failure state. By | |
523 | setting <varname>Restart=</varname> to | |
524 | <option>on-failure</option> or | |
e8ab3ccb LP |
525 | <option>always</option> the service |
526 | will be automatically restarted. The | |
527 | time configured here will be passed to | |
528 | the executed service process in the | |
529 | <varname>WATCHDOG_USEC=</varname> | |
dac051ad LP |
530 | environment variable. This allows |
531 | daemons to automatically enable the | |
532 | keep-alive pinging logic if watchdog | |
533 | support is enabled for the service. If | |
02c4ef9c LP |
534 | this option is used |
535 | <varname>NotifyAccess=</varname> (see | |
536 | below) should be set to open access to | |
537 | the notification socket provided by | |
538 | systemd. If | |
dac051ad LP |
539 | <varname>NotifyAccess=</varname> is |
540 | not set, it will be implicitly set to | |
02c4ef9c | 541 | <option>main</option>. Defaults to 0, |
e8ab3ccb LP |
542 | which disables this |
543 | feature.</para></listitem> | |
bb242b7b MO |
544 | </varlistentry> |
545 | ||
0d624a78 LP |
546 | <varlistentry> |
547 | <term><varname>Restart=</varname></term> | |
548 | <listitem><para>Configures whether the | |
50caaedb | 549 | main service process shall be |
f8553ccb | 550 | restarted when it exits. Takes one of |
525ee6f4 | 551 | <option>no</option>, |
50caaedb LP |
552 | <option>on-success</option>, |
553 | <option>on-failure</option>, | |
554 | <option>on-abort</option> or | |
555 | <option>always</option>. If set to | |
556 | <option>no</option> (the default) the | |
557 | service will not be restarted when it | |
558 | exits. If set to | |
559 | <option>on-success</option> it will be | |
560 | restarted only when it exited cleanly, | |
561 | i.e. terminated with an exit code of | |
562 | 0. If set to | |
563 | <option>on-failure</option> it will be | |
5471472d | 564 | restarted only when it exited with an |
092317d0 | 565 | exit code not equalling 0, when |
5389fedd LP |
566 | terminated by a signal (including on |
567 | core dump), when an operation (such as | |
568 | service reload) times out or when the | |
092317d0 LP |
569 | configured watchdog timeout is |
570 | triggered. If set to | |
50caaedb LP |
571 | <option>on-abort</option> it will be |
572 | restarted only if it exits due to | |
5389fedd LP |
573 | reception of an uncaught signal |
574 | (including on core dump). If set to | |
575 | <option>always</option> the service | |
576 | will be restarted regardless whether | |
577 | it exited cleanly or not, got | |
578 | terminated abnormally by a signal or | |
579 | hit a timeout.</para></listitem> | |
0d624a78 LP |
580 | </varlistentry> |
581 | ||
582 | <varlistentry> | |
583 | <term><varname>PermissionsStartOnly=</varname></term> | |
584 | <listitem><para>Takes a boolean | |
585 | argument. If true, the permission | |
586 | related execution options as | |
587 | configured with | |
588 | <varname>User=</varname> and similar | |
589 | options (see | |
590 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
591 | for more information) are only applied | |
592 | to the process started with | |
593 | <varname>ExecStart=</varname>, and not | |
594 | to the various other | |
595 | <varname>ExecStartPre=</varname>, | |
596 | <varname>ExecStartPost=</varname>, | |
597 | <varname>ExecReload=</varname>, | |
598 | <varname>ExecStop=</varname>, | |
599 | <varname>ExecStopPost=</varname> | |
600 | commands. If false, the setting is | |
601 | applied to all configured commands the | |
602 | same way. Defaults to | |
603 | false.</para></listitem> | |
604 | </varlistentry> | |
605 | ||
606 | <varlistentry> | |
607 | <term><varname>RootDirectoryStartOnly=</varname></term> | |
608 | <listitem><para>Takes a boolean | |
609 | argument. If true, the root directory | |
610 | as configured with the | |
611 | <varname>RootDirectory=</varname> | |
612 | option (see | |
613 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
614 | for more information) is only applied | |
615 | to the process started with | |
616 | <varname>ExecStart=</varname>, and not | |
617 | to the various other | |
618 | <varname>ExecStartPre=</varname>, | |
619 | <varname>ExecStartPost=</varname>, | |
620 | <varname>ExecReload=</varname>, | |
621 | <varname>ExecStop=</varname>, | |
622 | <varname>ExecStopPost=</varname> | |
623 | commands. If false, the setting is | |
624 | applied to all configured commands the | |
625 | same way. Defaults to | |
626 | false.</para></listitem> | |
627 | </varlistentry> | |
628 | ||
0d624a78 LP |
629 | <varlistentry> |
630 | <term><varname>NonBlocking=</varname></term> | |
631 | <listitem><para>Set O_NONBLOCK flag | |
632 | for all file descriptors passed via | |
633 | socket-based activation. If true, all | |
634 | file descriptors >= 3 (i.e. all except | |
635 | STDIN/STDOUT/STDERR) will have | |
636 | the O_NONBLOCK flag set and hence are in | |
637 | non-blocking mode. This option is only | |
638 | useful in conjunction with a socket | |
639 | unit, as described in | |
640 | <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>. Defaults | |
641 | to false.</para></listitem> | |
642 | </varlistentry> | |
643 | ||
644 | <varlistentry> | |
645 | <term><varname>NotifyAccess=</varname></term> | |
646 | <listitem><para>Controls access to the | |
647 | service status notification socket, as | |
648 | accessible via the | |
649 | <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
650 | call. Takes one of | |
651 | <option>none</option> (the default), | |
652 | <option>main</option> or | |
653 | <option>all</option>. If | |
654 | <option>none</option> no daemon status | |
f8553ccb | 655 | updates are accepted from the service |
0d624a78 LP |
656 | processes, all status update messages |
657 | are ignored. If <option>main</option> | |
658 | only service updates sent from the | |
659 | main process of the service are | |
660 | accepted. If <option>all</option> all | |
661 | services updates from all members of | |
662 | the service's control group are | |
02c4ef9c | 663 | accepted. This option should be set to |
0d624a78 LP |
664 | open access to the notification socket |
665 | when using | |
02c4ef9c LP |
666 | <varname>Type=notify</varname> or |
667 | <varname>WatchdogUsec=</varname> (see | |
668 | above). If those options are used but | |
669 | <varname>NotifyAccess=</varname> not | |
670 | configured it will be implicitly set | |
671 | to | |
672 | <option>main</option>.</para></listitem> | |
d1ab0ca0 LP |
673 | </varlistentry> |
674 | ||
f72192c0 LP |
675 | <varlistentry> |
676 | <term><varname>Sockets=</varname></term> | |
677 | <listitem><para>Specifies the name of | |
678 | the socket units this service shall | |
679 | inherit the sockets from when the | |
4f025f4c | 680 | service is started. Normally it |
f72192c0 LP |
681 | should not be necessary to use this |
682 | setting as all sockets whose unit | |
683 | shares the same name as the service | |
4f025f4c | 684 | (ignoring the different suffix of course) |
f72192c0 LP |
685 | are passed to the spawned |
686 | process.</para> | |
687 | ||
688 | <para>Note that the same socket may be | |
689 | passed to multiple processes at the | |
690 | same time. Also note that a different | |
691 | service may be activated on incoming | |
692 | traffic than inherits the sockets. Or | |
693 | in other words: The | |
694 | <varname>Service=</varname> setting of | |
695 | <filename>.socket</filename> units | |
696 | doesn't have to match the inverse of the | |
a1102c1f | 697 | <varname>Sockets=</varname> setting of |
f72192c0 LP |
698 | the <filename>.service</filename> it |
699 | refers to.</para></listitem> | |
700 | </varlistentry> | |
701 | ||
092317d0 LP |
702 | <varlistentry> |
703 | <term><varname>StartLimitInterval=</varname></term> | |
704 | <term><varname>StartLimitBurst=</varname></term> | |
705 | ||
706 | <listitem><para>Configure service | |
707 | start rate limiting. By default | |
708 | services which are started more often | |
709 | than 5 times within 10s are not | |
710 | permitted to start any more times | |
711 | until the 10s interval ends. With | |
712 | these two options this rate limiting | |
713 | may be modified. Use | |
714 | <varname>StartLimitInterval=</varname> | |
715 | to configure the checking interval | |
716 | (defaults to 10s, set to 0 to disable | |
717 | any kind of rate limiting). Use | |
718 | <varname>StartLimitBurst=</varname> to | |
719 | configure how many starts per interval | |
720 | are allowed (defaults to 5). These | |
721 | configuration options are particularly | |
722 | useful in conjunction with | |
6ffd3337 LP |
723 | <varname>Restart=</varname>, however |
724 | apply to all kinds of starts | |
725 | (including manual), not just those | |
726 | triggered by the | |
727 | <varname>Restart=</varname> logic. | |
728 | Note that units which are configured | |
729 | for <varname>Restart=</varname> and | |
730 | which reach the start limit are not | |
f1c8f75b LP |
731 | attempted to be restarted anymore, |
732 | however they may still be restarted | |
733 | manually at a later point from which | |
734 | point on the restart logic is again | |
451b34cc LP |
735 | activated. Note that |
736 | <command>systemctl | |
737 | reset-failed</command> will cause the | |
738 | restart rate counter for a service to | |
739 | be flushed, which is useful if the | |
740 | administrator wants to manually start | |
741 | a service and the start limit | |
742 | interferes with | |
743 | that.</para></listitem> | |
092317d0 LP |
744 | </varlistentry> |
745 | ||
746 | <varlistentry> | |
747 | <term><varname>StartLimitAction=</varname></term> | |
748 | ||
749 | <listitem><para>Configure the action | |
750 | to take if the rate limit configured | |
751 | with | |
752 | <varname>StartLimitInterval=</varname> | |
753 | and | |
754 | <varname>StartLimitBurst=</varname> is | |
755 | hit. Takes one of | |
756 | <option>none</option>, | |
757 | <option>reboot</option>, | |
758 | <option>reboot-force</option> or | |
759 | <option>reboot-immediate</option>. If | |
760 | <option>none</option> is set, | |
761 | hitting the rate limit will trigger no | |
762 | action besides that the start will not | |
763 | be | |
764 | permitted. <option>reboot</option> | |
765 | causes a reboot following the normal | |
766 | shutdown procedure (i.e. equivalent to | |
767 | <command>systemctl reboot</command>), | |
768 | <option>reboot-force</option> causes | |
769 | an forced reboot which will terminate | |
770 | all processes forcibly but should | |
771 | cause no dirty file systems on reboot | |
772 | (i.e. equivalent to <command>systemctl | |
773 | reboot -f</command>) and | |
774 | <option>reboot-immediate</option> | |
775 | causes immediate execution of the | |
776 | <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> | |
777 | system call, which might result in | |
778 | data loss. Defaults to | |
779 | <option>none</option>.</para></listitem> | |
780 | </varlistentry> | |
781 | ||
d1ab0ca0 | 782 | </variablelist> |
4819ff03 LP |
783 | |
784 | <para>Check | |
785 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
786 | and | |
787 | <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
788 | for more settings.</para> | |
789 | ||
d1ab0ca0 LP |
790 | </refsect1> |
791 | ||
c485d3ba LP |
792 | <refsect1> |
793 | <title>Compatibility Options</title> | |
794 | ||
795 | <para>The following options are also available in the | |
796 | <literal>[Service]</literal> section, but exist purely | |
797 | for compatibility reasons and should not be used in | |
798 | newly written service files.</para> | |
799 | ||
800 | <variablelist> | |
801 | <varlistentry> | |
802 | <term><varname>SysVStartPriority=</varname></term> | |
803 | <listitem><para>Set the SysV start | |
804 | priority to use to order this service | |
805 | in relation to SysV services lacking | |
806 | LSB headers. This option is only | |
807 | necessary to fix ordering in relation | |
808 | to legacy SysV services, that have no | |
809 | ordering information encoded in the | |
810 | script headers. As such it should only | |
811 | be used as temporary compatibility | |
812 | option, and not be used in new unit | |
813 | files. Almost always it is a better | |
814 | choice to add explicit ordering | |
815 | directives via | |
816 | <varname>After=</varname> or | |
817 | <varname>Before=</varname>, | |
818 | instead. For more details see | |
819 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. If | |
820 | used, pass an integer value in the | |
821 | range 0-99.</para></listitem> | |
822 | </varlistentry> | |
823 | ||
824 | <varlistentry> | |
825 | <term><varname>FsckPassNo=</varname></term> | |
826 | <listitem><para>Set the fsck passno | |
827 | priority to use to order this service | |
828 | in relation to other file system | |
829 | checking services. This option is only | |
830 | necessary to fix ordering in relation | |
831 | to fsck jobs automatically created for | |
832 | all <filename>/etc/fstab</filename> | |
833 | entries with a value in the fs_passno | |
834 | column > 0. As such it should only be | |
835 | used as option for fsck | |
836 | services. Almost always it is a better | |
837 | choice to add explicit ordering | |
838 | directives via | |
839 | <varname>After=</varname> or | |
840 | <varname>Before=</varname>, | |
841 | instead. For more details see | |
842 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. If | |
843 | used, pass an integer value in the | |
844 | same range as | |
845 | <filename>/etc/fstab</filename>'s | |
846 | fs_passno column. See | |
847 | <citerefentry><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
848 | for details.</para></listitem> | |
849 | </varlistentry> | |
850 | ||
851 | </variablelist> | |
852 | </refsect1> | |
853 | ||
d1ab0ca0 LP |
854 | <refsect1> |
855 | <title>See Also</title> | |
856 | <para> | |
f3e219a2 | 857 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, |
0d624a78 LP |
858 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>, |
859 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
4819ff03 LP |
860 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
861 | <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
d1ab0ca0 LP |
862 | </para> |
863 | </refsect1> | |
864 | ||
865 | </refentry> |