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