]>
Commit | Line | Data |
---|---|---|
d1ab0ca0 LP |
1 | <?xml version='1.0'?> <!--*-nxml-*--> |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" | |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
4 | ||
5 | <!-- | |
6 | This file is part of systemd. | |
7 | ||
8 | Copyright 2010 Lennart Poettering | |
9 | ||
10 | systemd is free software; you can redistribute it and/or modify it | |
11 | under the terms of the GNU General Public License as published by | |
12 | the Free Software Foundation; either version 2 of the License, or | |
13 | (at your option) any later version. | |
14 | ||
15 | systemd is distributed in the hope that it will be useful, but | |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 | General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU General Public License | |
21 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
22 | --> | |
23 | ||
24 | <refentry id="systemd.unit"> | |
25 | ||
26 | <refentryinfo> | |
27 | <title>systemd.unit</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.unit</refentrytitle> | |
42 | <manvolnum>5</manvolnum> | |
43 | </refmeta> | |
44 | ||
45 | <refnamediv> | |
46 | <refname>systemd.unit</refname> | |
47 | <refpurpose>systemd unit configuration files</refpurpose> | |
48 | </refnamediv> | |
49 | ||
50 | <refsynopsisdiv> | |
11e29955 LP |
51 | <para><filename>systemd.service</filename>, |
52 | <filename>systemd.socket</filename>, | |
53 | <filename>systemd.device</filename>, | |
54 | <filename>systemd.mount</filename>, | |
55 | <filename>systemd.automount</filename>, | |
56 | <filename>systemd.swap</filename>, | |
57 | <filename>systemd.target</filename>, | |
58 | <filename>systemd.path</filename>, | |
5f2ee303 LP |
59 | <filename>systemd.timer</filename>, |
60 | <filename>systemd.snapshot</filename></para> | |
d1ab0ca0 LP |
61 | </refsynopsisdiv> |
62 | ||
63 | <refsect1> | |
64 | <title>Description</title> | |
65 | ||
66 | <para>A unit configuration file encodes information | |
771610b0 | 67 | about a service, a socket, a device, a mount point, an |
436c44a5 | 68 | automount point, a swap file or partition, a start-up |
771610b0 | 69 | target, a file system path or a timer controlled and |
11e29955 LP |
70 | supervised by |
71 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>. The | |
72 | syntax is inspired by <ulink | |
73 | url="http://standards.freedesktop.org/desktop-entry-spec/latest/">XDG | |
4176e530 | 74 | Desktop Entry Specification</ulink> <filename>.desktop</filename> files, which are in turn |
11e29955 LP |
75 | inspired by Microsoft Windows |
76 | <filename>.ini</filename> files.</para> | |
d1ab0ca0 LP |
77 | |
78 | <para>This man pages lists the common configuration | |
58c16a1a | 79 | options of all the unit types. These options need to |
11e29955 | 80 | be configured in the [Unit] resp. [Install] |
771610b0 | 81 | section of the unit files.</para> |
11e29955 LP |
82 | |
83 | <para>In addition to the generic [Unit] and [Install] | |
58c16a1a | 84 | sections described here, each unit should have a |
11e29955 LP |
85 | type-specific section, e.g. [Service] for a service |
86 | unit. See the respective man pages for more | |
87 | information.</para> | |
88 | ||
89 | <para>Unit files may contain additional options on top | |
90 | of those listed here. If systemd encounters an unknown | |
91 | option it will write a warning log message but | |
92 | continue loading the unit. If an option is prefixed | |
93 | with <option>X-</option> it is ignored completely by | |
94 | systemd. Applications may use this to include | |
95 | additional information in the unit files.</para> | |
96 | ||
97 | <para>Boolean arguments used in unit files can be | |
6cbdbc5f | 98 | written in various formats. For positive settings the |
11e29955 LP |
99 | strings <option>1</option>, <option>yes</option>, |
100 | <option>true</option> and <option>on</option> are | |
101 | equivalent. For negative settings the strings | |
102 | <option>0</option>, <option>no</option>, | |
103 | <option>false</option> and <option>off</option> are | |
104 | equivalent.</para> | |
105 | ||
0d624a78 LP |
106 | <para>Time span values encoded in unit files can be |
107 | written in various formats. A stand-alone number | |
108 | specifies a time in seconds. If suffixed with a time | |
b439c6ee | 109 | unit, the unit is honored. A concatenation of |
58c16a1a | 110 | multiple values with units is supported, in which case |
0d624a78 LP |
111 | the values are added up. Example: "50" refers to 50 |
112 | seconds; "2min 200ms" refers to 2 minutes plus 200 | |
113 | milliseconds, i.e. 120200ms. The following time units | |
114 | are understood: s, min, h, d, w, ms, us.</para> | |
115 | ||
11e29955 | 116 | <para>Empty lines and lines starting with # or ; are |
b3eaa628 LP |
117 | ignored. This may be used for commenting. Lines ending |
118 | in a backslash are concatenated with the following | |
119 | line while reading and the backslash is replaced by a | |
120 | space character. This may be used to wrap long lines.</para> | |
11e29955 LP |
121 | |
122 | <para>If a line starts with <option>.include</option> | |
58c16a1a | 123 | followed by a file name, the specified file will be |
a70d9a77 BS |
124 | parsed at this point. Make sure that the file that is |
125 | included has the appropiate section headers before | |
126 | any directives.</para> | |
11e29955 LP |
127 | |
128 | <para>Along with a unit file | |
129 | <filename>foo.service</filename> a directory | |
130 | <filename>foo.service.wants/</filename> may exist. All | |
131 | units symlinked from such a directory are implicitly | |
132 | added as dependencies of type | |
133 | <varname>Wanted=</varname> to the unit. This is useful | |
134 | to hook units into the start-up of other units, | |
135 | without having to modify their unit configuration | |
136 | files. For details about the semantics of | |
137 | <varname>Wanted=</varname> see below. The preferred | |
138 | way to create symlinks in the | |
139 | <filename>.wants/</filename> directory of a service is | |
ee5762e3 LP |
140 | with the <command>enable</command> command of the |
141 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
11e29955 | 142 | tool which reads information from the [Install] |
0732ec00 LP |
143 | section of unit files. (See below.) A similar |
144 | functionality exists for <varname>Requires=</varname> | |
145 | type dependencies as well, the directory suffix is | |
146 | <filename>.requires/</filename> in this case.</para> | |
11e29955 LP |
147 | |
148 | <para>Note that while systemd offers a flexible | |
149 | dependency system between units it is recommended to | |
150 | use this functionality only sparsely and instead rely | |
151 | on techniques such as bus-based or socket-based | |
152 | activation which makes dependencies implicit, which | |
153 | both results in a simpler and more flexible | |
154 | system.</para> | |
1f812fea LP |
155 | |
156 | <para>Some unit names reflect paths existing in the | |
157 | file system name space. Example: a device unit | |
158 | <filename>dev-sda.device</filename> refers to a device | |
159 | with the device node <filename>/dev/sda</filename> in | |
160 | the file system namespace. If this applies a special | |
085b94ee LP |
161 | way to escape the path name is used, so that the |
162 | result is usable as part of a file name. Basically, | |
163 | given a path, "/" is replaced by "-", and all | |
164 | unprintable characters and the "-" are replaced by | |
165 | C-style "\x20" escapes. The root directory "/" is | |
166 | encoded as single dash, while otherwise the initial | |
167 | and ending "/" is removed from all paths during | |
168 | transformation. This escaping is reversible.</para> | |
1f812fea LP |
169 | |
170 | <para>Optionally, units may be instantiated from a | |
171 | template file at runtime. This allows creation of | |
172 | multiple units from a single configuration file. If | |
173 | systemd looks for a unit configuration file it will | |
174 | first search for the literal unit name in the | |
175 | filesystem. If that yields no success and the unit | |
176 | name contains an @ character, systemd will look for a | |
177 | unit template that shares the same name but with the | |
178 | instance string (i.e. the part between the @ character | |
179 | and the suffix) removed. Example: if a service | |
180 | <filename>getty@tty3.service</filename> is requested | |
181 | and no file by that name is found, systemd will look | |
182 | for <filename>getty@.service</filename> and | |
183 | instantiate a service from that configuration file if | |
0e89268b MB |
184 | it is found.</para> |
185 | ||
186 | <para>To refer to the instance string from | |
1f812fea LP |
187 | within the configuration file you may use the special |
188 | <literal>%i</literal> specifier in many of the | |
0e89268b MB |
189 | configuration options. Other specifiers exist, the |
190 | full list is:</para> | |
191 | ||
192 | <table> | |
193 | <title>Specifiers available in unit files</title> | |
194 | <tgroup cols='3' align='left' colsep='1' rowsep='1'> | |
195 | <colspec colname="spec" /> | |
196 | <colspec colname="mean" /> | |
197 | <colspec colname="detail" /> | |
198 | <thead> | |
199 | <row> | |
200 | <entry>Specifier</entry> | |
201 | <entry>Meaning</entry> | |
202 | <entry>Details</entry> | |
203 | </row> | |
204 | </thead> | |
205 | <tbody> | |
206 | <row> | |
207 | <entry><literal>%n</literal></entry> | |
208 | <entry>Full unit name</entry> | |
209 | <entry></entry> | |
210 | </row> | |
211 | <row> | |
212 | <entry><literal>%N</literal></entry> | |
213 | <entry>Unescaped full unit name</entry> | |
214 | <entry></entry> | |
215 | </row> | |
216 | <row> | |
217 | <entry><literal>%p</literal></entry> | |
218 | <entry>Prefix name</entry> | |
219 | <entry>This refers to the string before the @, i.e. "getty" in the example above, where "tty3" is the instance name.</entry> | |
220 | </row> | |
221 | <row> | |
222 | <entry><literal>%P</literal></entry> | |
223 | <entry>Unescaped prefix name</entry> | |
224 | <entry></entry> | |
225 | </row> | |
226 | <row> | |
227 | <entry><literal>%i</literal></entry> | |
228 | <entry>Instance name</entry> | |
229 | <entry>This is the string between the @ character and the suffix.</entry> | |
230 | </row> | |
231 | <row> | |
232 | <entry><literal>%I</literal></entry> | |
233 | <entry>Unescaped instance name</entry> | |
234 | <entry></entry> | |
235 | </row> | |
236 | <row> | |
237 | <entry><literal>%f</literal></entry> | |
238 | <entry>Unescaped file name</entry> | |
239 | <entry>This is either the unescaped instance name (if set) with / prepended (if necessary), or the prefix name similarly prepended with /.</entry> | |
240 | </row> | |
241 | <row> | |
242 | <entry><literal>%c</literal></entry> | |
243 | <entry>Control group path of the unit</entry> | |
244 | <entry></entry> | |
245 | </row> | |
246 | <row> | |
247 | <entry><literal>%r</literal></entry> | |
248 | <entry>Root control group path of systemd</entry> | |
249 | <entry></entry> | |
250 | </row> | |
251 | <row> | |
252 | <entry><literal>%R</literal></entry> | |
253 | <entry>Parent directory of the root control group path of systemd</entry> | |
254 | <entry></entry> | |
255 | </row> | |
256 | <row> | |
257 | <entry><literal>%t</literal></entry> | |
258 | <entry>Runtime socket dir</entry> | |
259 | <entry>This is either /run (for the system manager) or $XDG_RUNTIME_DIR (for user managers).</entry> | |
260 | </row> | |
261 | </tbody> | |
262 | </tgroup> | |
263 | </table> | |
b9aea954 | 264 | |
6daf4f90 LP |
265 | <para>If a unit file is empty (i.e. has the file size |
266 | 0) or is symlinked to <filename>/dev/null</filename> | |
267 | its configuration will not be loaded and it appears | |
268 | with a load state of <literal>masked</literal>, and | |
269 | cannot be activated. Use this as an effective way to | |
270 | fully disable a unit, making it impossible to start it | |
271 | even manually.</para> | |
272 | ||
b9aea954 LP |
273 | <para>The unit file format is covered by the |
274 | <ulink | |
275 | url="http://www.freedesktop.org/wiki/Software/systemd/InterfaceStabilityPromise">Interface | |
276 | Stability Promise</ulink>.</para> | |
d1ab0ca0 LP |
277 | </refsect1> |
278 | ||
279 | <refsect1> | |
280 | <title>Options</title> | |
281 | ||
771610b0 LP |
282 | <para>Unit file may include a [Unit] section, which |
283 | carries generic information about the unit that is not | |
284 | dependent on the type of unit:</para> | |
285 | ||
d1ab0ca0 | 286 | <variablelist> |
11e29955 LP |
287 | |
288 | <varlistentry> | |
289 | <term><varname>Description=</varname></term> | |
290 | <listitem><para>A free-form string | |
62adf224 LP |
291 | describing the unit. This is intended |
292 | for use in UIs to show descriptive | |
293 | information along with the unit | |
294 | name.</para></listitem> | |
11e29955 LP |
295 | </varlistentry> |
296 | ||
d1ab0ca0 | 297 | <varlistentry> |
9f235308 | 298 | <term><varname>Requires=</varname></term> |
771610b0 | 299 | |
11e29955 | 300 | <listitem><para>Configures requirement |
771610b0 | 301 | dependencies on other units. If this |
58c16a1a | 302 | unit gets activated, the units listed |
771610b0 LP |
303 | here will be activated as well. If one |
304 | of the other units gets deactivated or | |
305 | its activation fails, this unit will | |
306 | be deactivated. This option may be | |
307 | specified more than once, in which | |
308 | case requirement dependencies for all | |
11e29955 LP |
309 | listed names are created. Note that |
310 | requirement dependencies do not | |
311 | influence the order in which services | |
312 | are started or stopped. This has to be | |
313 | configured independently with the | |
314 | <varname>After=</varname> or | |
315 | <varname>Before=</varname> options. If | |
316 | a unit | |
317 | <filename>foo.service</filename> | |
318 | requires a unit | |
319 | <filename>bar.service</filename> as | |
320 | configured with | |
321 | <varname>Requires=</varname> and no | |
322 | ordering is configured with | |
323 | <varname>After=</varname> or | |
324 | <varname>Before=</varname>, then both | |
325 | units will be started simultaneously | |
326 | and without any delay between them if | |
327 | <filename>foo.service</filename> is | |
328 | activated. Often it is a better choice | |
329 | to use <varname>Wants=</varname> | |
330 | instead of | |
331 | <varname>Requires=</varname> in order | |
332 | to achieve a system that is more | |
333 | robust when dealing with failing | |
334 | services.</para></listitem> | |
d1ab0ca0 | 335 | </varlistentry> |
11e29955 | 336 | |
11e29955 LP |
337 | <varlistentry> |
338 | <term><varname>RequiresOverridable=</varname></term> | |
339 | ||
340 | <listitem><para>Similar to | |
341 | <varname>Requires=</varname>. | |
342 | Dependencies listed in | |
343 | <varname>RequiresOverridable=</varname> | |
344 | which cannot be fulfilled or fail to | |
58c16a1a | 345 | start are ignored if the startup was |
11e29955 LP |
346 | explicitly requested by the user. If |
347 | the start-up was pulled in indirectly | |
348 | by some dependency or automatic | |
349 | start-up of units that is not | |
350 | requested by the user this dependency | |
351 | must be fulfilled and otherwise the | |
352 | transaction fails. Hence, this option | |
353 | may be used to configure dependencies | |
4176e530 | 354 | that are normally honored unless the |
11e29955 LP |
355 | user explicitly starts up the unit, in |
356 | which case whether they failed or not | |
357 | is irrelevant.</para></listitem> | |
358 | ||
359 | </varlistentry> | |
360 | <varlistentry> | |
361 | <term><varname>Requisite=</varname></term> | |
362 | <term><varname>RequisiteOverridable=</varname></term> | |
363 | ||
364 | <listitem><para>Similar to | |
365 | <varname>Requires=</varname> | |
366 | resp. <varname>RequiresOverridable=</varname>. However, | |
367 | if a unit listed here is not started | |
368 | already it will not be started and the | |
369 | transaction fails | |
370 | immediately.</para></listitem> | |
371 | </varlistentry> | |
372 | ||
373 | <varlistentry> | |
374 | <term><varname>Wants=</varname></term> | |
375 | ||
376 | <listitem><para>A weaker version of | |
377 | <varname>Requires=</varname>. A unit | |
378 | listed in this option will be started | |
379 | if the configuring unit is. However, | |
58c16a1a | 380 | if the listed unit fails to start up |
11e29955 LP |
381 | or cannot be added to the transaction |
382 | this has no impact on the validity of | |
383 | the transaction as a whole. This is | |
384 | the recommended way to hook start-up | |
385 | of one unit to the start-up of another | |
386 | unit. Note that dependencies of this | |
387 | type may also be configured outside of | |
388 | the unit configuration file by | |
389 | adding a symlink to a | |
390 | <filename>.wants/</filename> directory | |
391 | accompanying the unit file. For | |
392 | details see above.</para></listitem> | |
393 | </varlistentry> | |
394 | ||
b81884e7 LP |
395 | <varlistentry> |
396 | <term><varname>BindTo=</varname></term> | |
397 | ||
398 | <listitem><para>Configures requirement | |
399 | dependencies, very similar in style to | |
400 | <varname>Requires=</varname>, however | |
401 | in addition to this behaviour it also | |
402 | declares that this unit is stopped | |
403 | when any of the units listed suddenly | |
404 | disappears. Units can suddenly, | |
405 | unexpectedly disappear if a service | |
406 | terminates on its own choice, a device | |
407 | is unplugged or a mount point | |
21931dbe | 408 | unmounted without involvement of |
b81884e7 LP |
409 | systemd.</para></listitem> |
410 | </varlistentry> | |
411 | ||
11e29955 LP |
412 | <varlistentry> |
413 | <term><varname>Conflicts=</varname></term> | |
414 | ||
415 | <listitem><para>Configures negative | |
416 | requirement dependencies. If a unit | |
58c16a1a | 417 | has a |
11e29955 | 418 | <varname>Conflicts=</varname> setting |
58c16a1a | 419 | on another unit, starting the former |
11e29955 LP |
420 | will stop the latter and vice |
421 | versa. Note that this setting is | |
422 | independent of and orthogonal to the | |
423 | <varname>After=</varname> and | |
424 | <varname>Before=</varname> ordering | |
69dd2852 LP |
425 | dependencies.</para> |
426 | ||
427 | <para>If a unit A that conflicts with | |
428 | a unit B is scheduled to be started at | |
429 | the same time as B, the transaction | |
430 | will either fail (in case both are | |
431 | required part of the transaction) or | |
432 | be modified to be fixed (in case one | |
433 | or both jobs are not a required part | |
434 | of the transaction). In the latter | |
435 | case the job that is not the required | |
436 | will be removed, or in case both are | |
437 | not required the unit that conflicts | |
438 | will be started and the unit that is | |
439 | conflicted is | |
440 | stopped.</para></listitem> | |
11e29955 LP |
441 | </varlistentry> |
442 | ||
443 | <varlistentry> | |
444 | <term><varname>Before=</varname></term> | |
445 | <term><varname>After=</varname></term> | |
446 | ||
447 | <listitem><para>Configures ordering | |
448 | dependencies between units. If a unit | |
449 | <filename>foo.service</filename> | |
450 | contains a setting | |
451 | <option>Before=bar.service</option> | |
58c16a1a | 452 | and both units are being started, |
11e29955 LP |
453 | <filename>bar.service</filename>'s |
454 | start-up is delayed until | |
455 | <filename>foo.service</filename> is | |
456 | started up. Note that this setting is | |
457 | independent of and orthogonal to the | |
458 | requirement dependencies as configured | |
459 | by <varname>Requires=</varname>. It is | |
460 | a common pattern to include a unit | |
461 | name in both the | |
462 | <varname>After=</varname> and | |
463 | <varname>Requires=</varname> option in | |
464 | which case the unit listed will be | |
465 | started before the unit that is | |
466 | configured with these options. This | |
467 | option may be specified more than | |
468 | once, in which case ordering | |
469 | dependencies for all listed names are | |
470 | created. <varname>After=</varname> is | |
471 | the inverse of | |
472 | <varname>Before=</varname>, i.e. while | |
473 | <varname>After=</varname> ensures that | |
474 | the configured unit is started after | |
475 | the listed unit finished starting up, | |
476 | <varname>Before=</varname> ensures the | |
477 | opposite, i.e. that the configured | |
478 | unit is fully started up before the | |
479 | listed unit is started. Note that when | |
480 | two units with an ordering dependency | |
481 | between them are shut down, the | |
58c16a1a | 482 | inverse of the start-up order is |
11e29955 LP |
483 | applied. i.e. if a unit is configured |
484 | with <varname>After=</varname> on | |
485 | another unit, the former is stopped | |
486 | before the latter if both are shut | |
487 | down. If one unit with an ordering | |
488 | dependency on another unit is shut | |
489 | down while the latter is started up, | |
490 | the shut down is ordered before the | |
491 | start-up regardless whether the | |
492 | ordering dependency is actually of | |
493 | type <varname>After=</varname> or | |
494 | <varname>Before=</varname>. If two | |
495 | units have no ordering dependencies | |
496 | between them they are shut down | |
497 | resp. started up simultaneously, and | |
498 | no ordering takes | |
499 | place. </para></listitem> | |
500 | </varlistentry> | |
501 | ||
b9975629 LP |
502 | <varlistentry> |
503 | <term><varname>OnFailure=</varname></term> | |
504 | ||
505 | <listitem><para>Lists one or more | |
506 | units that are activated when this | |
74ac3cbd MM |
507 | unit enters the |
508 | '<literal>failed</literal>' | |
509 | state.</para></listitem> | |
b9975629 LP |
510 | </varlistentry> |
511 | ||
4dcc1cb4 LP |
512 | <varlistentry> |
513 | <term><varname>PropagateReloadTo=</varname></term> | |
514 | <term><varname>PropagateReloadFrom=</varname></term> | |
515 | ||
516 | <listitem><para>Lists one or more | |
517 | units where reload requests on the | |
518 | unit will be propagated to/on the | |
519 | other unit will be propagated | |
520 | from. Issuing a reload request on a | |
521 | unit will automatically also enqueue a | |
522 | reload request on all units that the | |
523 | reload request shall be propagated to | |
524 | via these two | |
525 | settings.</para></listitem> | |
526 | </varlistentry> | |
527 | ||
222ae6a8 LP |
528 | <varlistentry> |
529 | <term><varname>OnFailureIsolate=</varname></term> | |
530 | ||
531 | <listitem><para>Takes a boolean | |
532 | argument. If <option>true</option> the | |
533 | unit listed in | |
534 | <varname>OnFailure=</varname> will be | |
535 | enqueued in isolation mode, i.e. all | |
536 | units that are not its dependency will | |
537 | be stopped. If this is set only a | |
538 | single unit may be listed in | |
539 | <varname>OnFailure=</varname>. Defaults | |
540 | to | |
541 | <option>false</option>.</para></listitem> | |
542 | </varlistentry> | |
543 | ||
c8f4d764 LP |
544 | <varlistentry> |
545 | <term><varname>IgnoreOnIsolate=</varname></term> | |
546 | ||
547 | <listitem><para>Takes a boolean | |
548 | argument. If <option>true</option> | |
549 | this unit will not be stopped when | |
550 | isolating another unit. Defaults to | |
551 | <option>false</option>.</para></listitem> | |
552 | </varlistentry> | |
553 | ||
7a6000a6 LP |
554 | <varlistentry> |
555 | <term><varname>IgnoreOnSnapshot=</varname></term> | |
556 | ||
557 | <listitem><para>Takes a boolean | |
558 | argument. If <option>true</option> | |
559 | this unit will not be included in | |
560 | snapshots. Defaults to | |
4e7f8bc8 ZJS |
561 | <option>true</option> for device and |
562 | snapshot units, <option>false</option> | |
7a6000a6 LP |
563 | for the others.</para></listitem> |
564 | </varlistentry> | |
565 | ||
11e29955 LP |
566 | <varlistentry> |
567 | <term><varname>StopWhenUnneeded=</varname></term> | |
568 | ||
569 | <listitem><para>Takes a boolean | |
570 | argument. If <option>true</option> | |
571 | this unit will be stopped when it is | |
572 | no longer used. Note that in order to | |
58c16a1a OÇ |
573 | minimize the work to be executed, |
574 | systemd will not stop units by default | |
11e29955 LP |
575 | unless they are conflicting with other |
576 | units, or the user explicitly | |
577 | requested their shut down. If this | |
58c16a1a | 578 | option is set, a unit will be |
11e29955 LP |
579 | automatically cleaned up if no other |
580 | active unit requires it. Defaults to | |
581 | <option>false</option>.</para></listitem> | |
582 | </varlistentry> | |
583 | ||
584 | <varlistentry> | |
b5e9dba8 LP |
585 | <term><varname>RefuseManualStart=</varname></term> |
586 | <term><varname>RefuseManualStop=</varname></term> | |
11e29955 LP |
587 | |
588 | <listitem><para>Takes a boolean | |
589 | argument. If <option>true</option> | |
58c16a1a | 590 | this unit can only be activated |
b5e9dba8 LP |
591 | (resp. deactivated) indirectly. In |
592 | this case explicit start-up | |
593 | (resp. termination) requested by the | |
594 | user is denied, however if it is | |
595 | started (resp. stopped) as a | |
58c16a1a | 596 | dependency of another unit, start-up |
b5e9dba8 LP |
597 | (resp. termination) will succeed. This |
598 | is mostly a safety feature to ensure | |
599 | that the user does not accidentally | |
600 | activate units that are not intended | |
601 | to be activated explicitly, and not | |
602 | accidentally deactivate units that are | |
603 | not intended to be deactivated. | |
604 | These options default to | |
11e29955 LP |
605 | <option>false</option>.</para></listitem> |
606 | </varlistentry> | |
607 | ||
2528a7a6 LP |
608 | <varlistentry> |
609 | <term><varname>AllowIsolate=</varname></term> | |
610 | ||
611 | <listitem><para>Takes a boolean | |
612 | argument. If <option>true</option> | |
613 | this unit may be used with the | |
614 | <command>systemctl isolate</command> | |
615 | command. Otherwise this will be | |
616 | refused. It probably is a good idea to | |
617 | leave this disabled except for target | |
618 | units that shall be used similar to | |
619 | runlevels in SysV init systems, just | |
620 | as a precaution to avoid unusable | |
621 | system states. This option defaults to | |
622 | <option>false</option>.</para></listitem> | |
623 | </varlistentry> | |
624 | ||
62adf224 LP |
625 | <varlistentry> |
626 | <term><varname>DefaultDependencies=</varname></term> | |
627 | ||
628 | <listitem><para>Takes a boolean | |
629 | argument. If <option>true</option> | |
630 | (the default), a few default | |
631 | dependencies will implicitly be | |
632 | created for the unit. The actual | |
633 | dependencies created depend on the | |
634 | unit type. For example, for service | |
635 | units, these dependencies ensure that | |
636 | the service is started only after | |
637 | basic system initialization is | |
58c16a1a | 638 | completed and is properly terminated on |
62adf224 LP |
639 | system shutdown. See the respective |
640 | man pages for details. Generally, only | |
641 | services involved with early boot or | |
642 | late shutdown should set this option | |
643 | to <option>false</option>. It is | |
644 | highly recommended to leave this | |
645 | option enabled for the majority of | |
646 | common units. If set to | |
647 | <option>false</option> this option | |
648 | does not disable all implicit | |
649 | dependencies, just non-essential | |
650 | ones.</para></listitem> | |
651 | </varlistentry> | |
652 | ||
b9975629 LP |
653 | <varlistentry> |
654 | <term><varname>JobTimeoutSec=</varname></term> | |
655 | ||
656 | <listitem><para>When clients are | |
657 | waiting for a job of this unit to | |
658 | complete, time out after the specified | |
659 | time. If this time limit is reached | |
660 | the job will be cancelled, the unit | |
661 | however will not change state or even | |
74ac3cbd MM |
662 | enter the '<literal>failed</literal>' |
663 | mode. This value defaults to 0 (job | |
664 | timeouts disabled), except for device | |
665 | units. NB: this timeout is independent | |
666 | from any unit-specific timeout (for | |
667 | example, the timeout set with | |
b9975629 | 668 | <varname>Timeout=</varname> in service |
74ac3cbd MM |
669 | units) as the job timeout has no |
670 | effect on the unit itself, only on the | |
671 | job that might be pending for it. Or | |
672 | in other words: unit-specific timeouts | |
b9975629 LP |
673 | are useful to abort unit state |
674 | changes, and revert them. The job | |
675 | timeout set with this option however | |
74ac3cbd MM |
676 | is useful to abort only the job |
677 | waiting for the unit state to | |
678 | change.</para></listitem> | |
b9975629 LP |
679 | </varlistentry> |
680 | ||
52661efd LP |
681 | <varlistentry> |
682 | <term><varname>ConditionPathExists=</varname></term> | |
8092a428 | 683 | <term><varname>ConditionPathExistsGlob=</varname></term> |
c61e77d3 | 684 | <term><varname>ConditionPathIsDirectory=</varname></term> |
0d60602c | 685 | <term><varname>ConditionPathIsSymbolicLink=</varname></term> |
ab7f148f | 686 | <term><varname>ConditionPathIsMountPoint=</varname></term> |
36af55d9 | 687 | <term><varname>ConditionDirectoryNotEmpty=</varname></term> |
82e487c5 | 688 | <term><varname>ConditionFileIsExecutable=</varname></term> |
52661efd | 689 | <term><varname>ConditionKernelCommandLine=</varname></term> |
039655a4 | 690 | <term><varname>ConditionVirtualization=</varname></term> |
69528c31 | 691 | <term><varname>ConditionSecurity=</varname></term> |
62590f23 | 692 | <term><varname>ConditionCapability=</varname></term> |
d257ddef | 693 | <term><varname>ConditionNull=</varname></term> |
52661efd LP |
694 | |
695 | <listitem><para>Before starting a unit | |
696 | verify that the specified condition is | |
697 | true. With | |
698 | <varname>ConditionPathExists=</varname> | |
9f7dad77 | 699 | a file existence condition can be |
52661efd LP |
700 | checked before a unit is started. If |
701 | the specified absolute path name does | |
418112a2 | 702 | not exist, startup of a unit will not |
52661efd LP |
703 | actually happen, however the unit is |
704 | still useful for ordering purposes in | |
705 | this case. The condition is checked at | |
706 | the time the queued start job is to be | |
707 | executed. If the absolute path name | |
708 | passed to | |
709 | <varname>ConditionPathExists=</varname> | |
710 | is prefixed with an exclamation mark | |
711 | (!), the test is negated, and the unit | |
418112a2 | 712 | is only started if the path does not |
8571962c | 713 | exist. |
418112a2 MS |
714 | <varname>ConditionPathExistsGlob=</varname> |
715 | works in a similar way, but checks for | |
716 | the existence of at least one file or | |
8092a428 | 717 | directory matching the specified |
ab7f148f LP |
718 | globbing |
719 | pattern. <varname>ConditionPathIsDirectory=</varname> | |
720 | is similar to | |
721 | <varname>ConditionPathExists=</varname> | |
722 | but verifies whether a certain path | |
8571962c | 723 | exists and is a |
0d60602c MS |
724 | directory. <varname>ConditionPathIsSymbolicLink=</varname> |
725 | is similar to | |
726 | <varname>ConditionPathExists=</varname> | |
727 | but verifies whether a certain path | |
8095200d LP |
728 | exists and is a symbolic |
729 | link. <varname>ConditionPathIsMountPoint=</varname> | |
ab7f148f LP |
730 | is similar to |
731 | <varname>ConditionPathExists=</varname> | |
732 | but verifies whether a certain path | |
733 | exists and is a mount | |
734 | point. <varname>ConditionFileIsExecutable=</varname> | |
735 | is similar to | |
736 | <varname>ConditionPathExists=</varname> | |
737 | but verifies whether a certain path | |
738 | exists, is a regular file and marked | |
8571962c | 739 | executable. |
c61e77d3 LP |
740 | <varname>ConditionDirectoryNotEmpty=</varname> |
741 | is similar to | |
742 | <varname>ConditionPathExists=</varname> | |
743 | but verifies whether a certain path | |
36af55d9 LP |
744 | exists and is a non-empty |
745 | directory. Similarly | |
52661efd LP |
746 | <varname>ConditionKernelCommandLine=</varname> |
747 | may be used to check whether a | |
748 | specific kernel command line option is | |
749 | set (or if prefixed with the | |
750 | exclamation mark unset). The argument | |
751 | must either be a single word, or an | |
5471472d | 752 | assignment (i.e. two words, separated |
52661efd | 753 | by the equality sign). In the former |
d257ddef LP |
754 | case the kernel command line is |
755 | searched for the word appearing as is, | |
756 | or as left hand side of an | |
757 | assignment. In the latter case the | |
758 | exact assignment is looked for with | |
759 | right and left hand side | |
039655a4 LP |
760 | matching. <varname>ConditionVirtualization=</varname> |
761 | may be used to check whether the | |
762 | system is executed in a virtualized | |
763 | environment and optionally test | |
764 | whether it is a specific | |
765 | implementation. Takes either boolean | |
267632f0 | 766 | value to check if being executed in |
8095200d LP |
767 | any virtualized environment, or one of |
768 | <varname>vm</varname> and | |
62590f23 LP |
769 | <varname>container</varname> to test |
770 | against a specific type of | |
771 | virtualization solution, or one of | |
039655a4 LP |
772 | <varname>qemu</varname>, |
773 | <varname>kvm</varname>, | |
774 | <varname>vmware</varname>, | |
775 | <varname>microsoft</varname>, | |
776 | <varname>oracle</varname>, | |
777 | <varname>xen</varname>, | |
8095200d LP |
778 | <varname>bochs</varname>, |
779 | <varname>chroot</varname>, | |
65bc2c21 LP |
780 | <varname>openvz</varname>, |
781 | <varname>lxc</varname>, | |
7d39db92 | 782 | <varname>lxc-libvirt</varname>, |
65bc2c21 LP |
783 | <varname>systemd-nspawn</varname>, |
784 | <varname>pidns</varname> to test | |
785 | against a specific implementation. If | |
786 | multiple virtualization technologies | |
787 | are nested only the innermost is | |
788 | considered. The test may be negated by | |
789 | prepending an exclamation mark. | |
69528c31 | 790 | <varname>ConditionSecurity=</varname> |
8092a428 LP |
791 | may be used to check whether the given |
792 | security module is enabled on the | |
793 | system. Currently the only recognized | |
794 | value is <varname>selinux</varname>. | |
795 | The test may be negated by prepending | |
62590f23 LP |
796 | an exclamation |
797 | mark. <varname>ConditionCapability=</varname> | |
798 | may be used to check whether the given | |
799 | capability exists in the capability | |
800 | bounding set of the service manager | |
801 | (i.e. this does not check whether | |
802 | capability is actually available in | |
803 | the permitted or effective sets, see | |
804 | <citerefentry><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry> | |
805 | for details). Pass a capability name | |
806 | such as <literal>CAP_MKNOD</literal>, | |
807 | possibly prefixed with an exclamation | |
808 | mark to negate the check. Finally, | |
d257ddef LP |
809 | <varname>ConditionNull=</varname> may |
810 | be used to add a constant condition | |
811 | check value to the unit. It takes a | |
812 | boolean argument. If set to | |
813 | <varname>false</varname> the condition | |
814 | will always fail, otherwise | |
815 | succeed. If multiple conditions are | |
039655a4 | 816 | specified the unit will be executed if |
267632f0 LP |
817 | all of them apply (i.e. a logical AND |
818 | is applied). Condition checks can be | |
819 | prefixed with a pipe symbol (|) in | |
820 | which case a condition becomes a | |
821 | triggering condition. If at least one | |
822 | triggering condition is defined for a | |
823 | unit then the unit will be executed if | |
824 | at least one of the triggering | |
825 | conditions apply and all of the | |
826 | non-triggering conditions. If you | |
827 | prefix an argument with the pipe | |
828 | symbol and an exclamation mark the | |
829 | pipe symbol must be passed first, the | |
0d60602c MS |
830 | exclamation second. Except for |
831 | <varname>ConditionPathIsSymbolicLink=</varname>, | |
65bc2c21 LP |
832 | all path checks follow |
833 | symlinks.</para></listitem> | |
52661efd | 834 | </varlistentry> |
e2130f18 LP |
835 | |
836 | <varlistentry> | |
837 | <term><varname>Names=</varname></term> | |
838 | ||
839 | <listitem><para>Additional names for | |
840 | this unit. The names listed here must | |
841 | have the same suffix (i.e. type) as | |
842 | the unit file name. This option may be | |
843 | specified more than once, in which | |
844 | case all listed names are used. Note | |
845 | that this option is different from the | |
846 | <varname>Alias=</varname> option from | |
847 | the [Install] section mentioned | |
848 | below. See below for details. Note | |
849 | that in almost all cases this option | |
850 | is not what you want. A symlink alias | |
851 | in the file system is generally | |
852 | preferable since it can be used as | |
853 | lookup key. If a unit with a symlinked | |
854 | alias name is not loaded and needs to | |
855 | be it is easily found via the | |
856 | symlink. However, if a unit with an | |
857 | alias name configured with this | |
858 | setting is not loaded it will not be | |
859 | discovered. This settings' only use is | |
860 | in conjunction with service | |
861 | instances.</para> | |
862 | </listitem> | |
863 | </varlistentry> | |
d1ab0ca0 | 864 | </variablelist> |
771610b0 LP |
865 | |
866 | <para>Unit file may include a [Install] section, which | |
867 | carries installation information for the unit. This | |
868 | section is not interpreted by | |
869 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
870 | during runtime. It is used exclusively by the | |
ee5762e3 LP |
871 | <command>enable</command> and |
872 | <command>disable</command> commands of the | |
873 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
11e29955 | 874 | tool during installation of a unit:</para> |
771610b0 LP |
875 | |
876 | <variablelist> | |
877 | <varlistentry> | |
878 | <term><varname>Alias=</varname></term> | |
879 | ||
0a715d97 | 880 | <listitem><para>Additional names this |
771610b0 LP |
881 | unit shall be installed under. The |
882 | names listed here must have the same | |
883 | suffix (i.e. type) as the unit file | |
884 | name. This option may be specified | |
885 | more than once, in which case all | |
886 | listed names are used. At installation | |
af62c704 | 887 | time, |
ee5762e3 | 888 | <command>systemctl enable</command> |
771610b0 LP |
889 | will create symlinks from these names |
890 | to the unit file name. Note that this | |
891 | is different from the | |
892 | <varname>Names=</varname> option from | |
893 | the [Unit] section mentioned above: | |
894 | The names from | |
895 | <varname>Names=</varname> apply | |
896 | unconditionally if the unit is | |
897 | loaded. The names from | |
898 | <varname>Alias=</varname> apply only | |
11e29955 LP |
899 | if the unit has actually been |
900 | installed with the | |
ee5762e3 LP |
901 | <command>systemctl enable</command> |
902 | command. Also, if systemd searches for a | |
771610b0 | 903 | unit, it will discover symlinked alias |
11e29955 LP |
904 | names as configured with |
905 | <varname>Alias=</varname>, but not | |
906 | names configured with | |
907 | <varname>Names=</varname> only. It is | |
908 | a common pattern to list a name in | |
909 | both options. In this case, a unit | |
910 | will be active under all names if | |
911 | installed, but also if not installed | |
912 | but requested explicitly under its | |
913 | main name.</para></listitem> | |
914 | </varlistentry> | |
915 | ||
916 | <varlistentry> | |
917 | <term><varname>WantedBy=</varname></term> | |
918 | ||
919 | <listitem><para>Installs a symlink in | |
920 | the <filename>.wants/</filename> | |
921 | subdirectory for a unit. This has the | |
922 | effect that when the listed unit name | |
923 | is activated the unit listing it is | |
924 | activated | |
6cbdbc5f | 925 | too. <command>WantedBy=foo.service</command> |
11e29955 LP |
926 | in a service |
927 | <filename>bar.service</filename> is | |
928 | mostly equivalent to | |
929 | <command>Alias=foo.service.wants/bar.service</command> | |
930 | in the same file.</para></listitem> | |
931 | </varlistentry> | |
932 | ||
933 | <varlistentry> | |
934 | <term><varname>Also=</varname></term> | |
935 | ||
936 | <listitem><para>Additional units to | |
937 | install when this unit is | |
938 | installed. If the user requests | |
939 | installation of a unit with this | |
58c16a1a | 940 | option configured, |
ee5762e3 | 941 | <command>systemctl enable</command> |
11e29955 LP |
942 | will automatically install units |
943 | listed in this option as | |
944 | well.</para></listitem> | |
771610b0 LP |
945 | </varlistentry> |
946 | </variablelist> | |
947 | ||
d1ab0ca0 LP |
948 | </refsect1> |
949 | ||
950 | <refsect1> | |
160cd5c9 LP |
951 | <title>See Also</title> |
952 | <para> | |
953 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
771610b0 | 954 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>, |
771610b0 LP |
955 | <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>, |
956 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
957 | <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
958 | <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
959 | <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
960 | <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
961 | <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
962 | <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
963 | <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
5f2ee303 | 964 | <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
62590f23 LP |
965 | <citerefentry><refentrytitle>systemd.snapshot</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
966 | <citerefentry><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry> | |
160cd5c9 | 967 | </para> |
d1ab0ca0 LP |
968 | </refsect1> |
969 | ||
970 | </refentry> |