Debian Codegraph @

upstream/fedora-44/man5/systemd.service.5

raw
1 '\" t
2 .TH "SYSTEMD\&.SERVICE" "5" "" "systemd 259.5" "systemd.service"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 systemd.service \- Service unit configuration
24 .SH "SYNOPSIS"
25 .PP
26 \fIservice\fR\&.service
27 .SH "DESCRIPTION"
28 .PP
29 A unit configuration file whose name ends in
30 "\&.service"
31 encodes information about a process controlled and supervised by systemd\&.
32 .PP
33 This man page lists the configuration options specific to this unit type\&. See
34 \fBsystemd.unit\fR(5)
35 for the common options of all unit configuration files\&. The common configuration items are configured in the generic [Unit] and [Install] sections\&. The service specific configuration options are configured in the [Service] section\&.
36 .PP
37 Additional options are listed in
38 \fBsystemd.exec\fR(5), which define the execution environment the commands are executed in, and in
39 \fBsystemd.kill\fR(5), which define the way the processes of the service are terminated, and in
40 \fBsystemd.resource-control\fR(5), which configure resource control settings for the processes of the service\&.
41 .PP
42 If SysV init compat is enabled, systemd automatically creates service units that wrap SysV init scripts (the service name is the same as the name of the script, with a
43 "\&.service"
44 suffix added); see
45 \fBsystemd-sysv-generator\fR(8)\&.
46 .PP
47 The
48 \fBsystemd-run\fR(1)
49 command allows creating
50 \&.service
51 and
52 \&.scope
53 units dynamically and transiently from the command line\&.
54 .SH "SERVICE TEMPLATES"
55 .PP
56 It is possible for
57 \fBsystemd\fR
58 services to take a single argument via the
59 "\fIservice\fR@\fIargument\fR\&.service"
60 syntax\&. Such services are called "instantiated" services, while the unit definition without the
61 \fIargument\fR
62 parameter is called a "template"\&. An example could be a
63 dhcpcd@\&.service
64 service template which takes a network interface as a parameter to form an instantiated service\&. Within the service file, this parameter or "instance name" can be accessed with %\-specifiers\&. See
65 \fBsystemd.unit\fR(5)
66 for details\&.
67 .SH "AUTOMATIC DEPENDENCIES"
68 .SS "Implicit Dependencies"
69 .PP
70 The following dependencies are implicitly added:
71 .sp
72 .RS 4
73 .ie n \{\
74 \h'-04'\(bu\h'+03'\c
75 .\}
76 .el \{\
77 .sp -1
78 .IP \(bu 2.3
79 .\}
80 Services with
81 \fIType=dbus\fR
82 set automatically acquire dependencies of type
83 \fIRequires=\fR
84 and
85 \fIAfter=\fR
86 on
87 dbus\&.socket\&.
88 .RE
89 .sp
90 .RS 4
91 .ie n \{\
92 \h'-04'\(bu\h'+03'\c
93 .\}
94 .el \{\
95 .sp -1
96 .IP \(bu 2.3
97 .\}
98 Socket activated services are automatically ordered after their activating
99 \&.socket
100 units via an automatic
101 \fIAfter=\fR
102 dependency\&. Services also pull in all
103 \&.socket
104 units listed in
105 \fISockets=\fR
106 via automatic
107 \fIWants=\fR
108 and
109 \fIAfter=\fR
110 dependencies\&.
111 .RE
112 .PP
113 Additional implicit dependencies may be added as result of execution and resource control parameters as documented in
114 \fBsystemd.exec\fR(5)
115 and
116 \fBsystemd.resource-control\fR(5)\&.
117 .SS "Default Dependencies"
118 .PP
119 The following dependencies are added unless
120 \fIDefaultDependencies=no\fR
121 is set:
122 .sp
123 .RS 4
124 .ie n \{\
125 \h'-04'\(bu\h'+03'\c
126 .\}
127 .el \{\
128 .sp -1
129 .IP \(bu 2.3
130 .\}
131 Service units will have dependencies of type
132 \fIRequires=\fR
133 and
134 \fIAfter=\fR
135 on
136 sysinit\&.target, a dependency of type
137 \fIAfter=\fR
138 on
139 basic\&.target
140 as well as dependencies of type
141 \fIConflicts=\fR
142 and
143 \fIBefore=\fR
144 on
145 shutdown\&.target\&. These ensure that normal service units pull in basic system initialization, and are terminated cleanly prior to system shutdown\&. Only services involved with early boot or late system shutdown should disable this option\&.
146 .RE
147 .sp
148 .RS 4
149 .ie n \{\
150 \h'-04'\(bu\h'+03'\c
151 .\}
152 .el \{\
153 .sp -1
154 .IP \(bu 2.3
155 .\}
156 Instanced service units (i\&.e\&. service units with an
157 "@"
158 in their name) are assigned by default a per\-template slice unit (see
159 \fBsystemd.slice\fR(5)), named after the template unit, containing all instances of the specific template\&. This slice is normally stopped at shutdown, together with all template instances\&. If that is not desired, set
160 \fIDefaultDependencies=no\fR
161 in the template unit, and either define your own per\-template slice unit file that also sets
162 \fIDefaultDependencies=no\fR, or set
163 \fISlice=system\&.slice\fR
164 (or another suitable slice) in the template unit\&. Also see
165 \fBsystemd.resource-control\fR(5)\&.
166 .RE
167 .SH "OPTIONS"
168 .PP
169 Service unit files may include [Unit] and [Install] sections, which are described in
170 \fBsystemd.unit\fR(5)\&.
171 .PP
172 Service unit files must include a [Service] section, which carries information about the service and the process it supervises\&. A number of options that may be used in this section are shared with other unit types\&. These options are documented in
173 \fBsystemd.exec\fR(5),
174 \fBsystemd.kill\fR(5)
175 and
176 \fBsystemd.resource-control\fR(5)\&. The options specific to the [Service] section of service units are the following:
177 .PP
178 \fIType=\fR
179 .RS 4
180 Configures the mechanism via which the service notifies the manager that the service start\-up has finished\&. One of
181 \fBsimple\fR,
182 \fBexec\fR,
183 \fBforking\fR,
184 \fBoneshot\fR,
185 \fBdbus\fR,
186 \fBnotify\fR,
187 \fBnotify\-reload\fR, or
188 \fBidle\fR:
189 .sp
190 .RS 4
191 .ie n \{\
192 \h'-04'\(bu\h'+03'\c
193 .\}
194 .el \{\
195 .sp -1
196 .IP \(bu 2.3
197 .\}
198 If set to
199 \fBsimple\fR
200 (the default if
201 \fIExecStart=\fR
202 is specified but neither
203 \fIType=\fR
204 nor
205 \fIBusName=\fR
206 are, and credentials are not used), the service manager will consider the unit started immediately after the main service process has been forked off (i\&.e\&. immediately after
207 \fBfork()\fR, and before various process attributes have been configured and in particular before the new process has called
208 \fBexecve()\fR
209 to invoke the actual service binary)\&. Typically,
210 \fIType=\fR\fBexec\fR
211 is the better choice, see below\&.
212 .sp
213 It is expected that the process configured with
214 \fIExecStart=\fR
215 is the main process of the service\&. In this mode, if the process offers functionality to other processes on the system, its communication channels should be installed before the service is started up (e\&.g\&. sockets set up by systemd, via socket activation), as the service manager will immediately proceed starting follow\-up units, right after creating the main service process, and before executing the service\*(Aqs binary\&. Note that this means
216 \fBsystemctl start\fR
217 command lines for
218 \fBsimple\fR
219 services will report success even if the service\*(Aqs binary cannot be invoked successfully (for example because the selected
220 \fIUser=\fR
221 does not exist, or the service binary is missing)\&.
222 .RE
223 .sp
224 .RS 4
225 .ie n \{\
226 \h'-04'\(bu\h'+03'\c
227 .\}
228 .el \{\
229 .sp -1
230 .IP \(bu 2.3
231 .\}
232 The
233 \fBexec\fR
234 type is similar to
235 \fBsimple\fR, but the service manager will consider the unit started immediately after the main service binary has been executed\&. The service manager will delay starting of follow\-up units until that point\&. (Or in other words:
236 \fBsimple\fR
237 proceeds with further jobs right after
238 \fBfork()\fR
239 returns, while
240 \fBexec\fR
241 will not proceed before both
242 \fBfork()\fR
243 and
244 \fBexecve()\fR
245 in the service process succeeded\&.) Note that this means
246 \fBsystemctl start\fR
247 command lines for
248 \fBexec\fR
249 services will report failure when the service\*(Aqs binary cannot be invoked successfully (for example because the selected
250 \fIUser=\fR
251 does not exist, or the service binary is missing)\&. This type is implied if credentials are used (refer to
252 \fILoadCredential=\fR
253 in
254 \fBsystemd.exec\fR(5)
255 for details)\&.
256 .RE
257 .sp
258 .RS 4
259 .ie n \{\
260 \h'-04'\(bu\h'+03'\c
261 .\}
262 .el \{\
263 .sp -1
264 .IP \(bu 2.3
265 .\}
266 If set to
267 \fBforking\fR, the manager will consider the unit started immediately after the binary that forked off by the manager exits\&.
268 \fIThe use of this type is discouraged, use \fR\fI\fBnotify\fR\fR\fI, \fR\fI\fBnotify\-reload\fR\fR\fI, or \fR\fI\fBdbus\fR\fR\fI instead\&.\fR
269 .sp
270 It is expected that the process configured with
271 \fIExecStart=\fR
272 will call
273 \fBfork()\fR
274 as part of its start\-up\&. The parent process is expected to exit when start\-up is complete and all communication channels are set up\&. The child continues to run as the main service process, and the service manager will consider the unit started when the parent process exits\&. This is the behavior of traditional UNIX services\&. If this setting is used, it is recommended to also use the
275 \fIPIDFile=\fR
276 option, so that systemd can reliably identify the main process of the service\&. The manager will proceed with starting follow\-up units after the parent process exits\&.
277 .RE
278 .sp
279 .RS 4
280 .ie n \{\
281 \h'-04'\(bu\h'+03'\c
282 .\}
283 .el \{\
284 .sp -1
285 .IP \(bu 2.3
286 .\}
287 Behavior of
288 \fBoneshot\fR
289 is similar to
290 \fBexec\fR; however, the service manager will consider the unit up after the main process exits\&. It will then start follow\-up units\&.
291 \fIRemainAfterExit=\fR
292 is particularly useful for this type of service\&.
293 \fIType=\fR\fBoneshot\fR
294 is the implied default if neither
295 \fIType=\fR
296 nor
297 \fIExecStart=\fR
298 are specified\&. Note that if this option is used without
299 \fIRemainAfterExit=\fR
300 the service will never enter
301 "active"
302 unit state, but will directly transition from
303 "activating"
304 to
305 "deactivating"
306 or
307 "dead", since no process is configured that shall run continuously\&. In particular this means that after a service of this type ran (and which has
308 \fIRemainAfterExit=\fR
309 not set) it will not show up as started afterwards, but as dead\&.
310 .RE
311 .sp
312 .RS 4
313 .ie n \{\
314 \h'-04'\(bu\h'+03'\c
315 .\}
316 .el \{\
317 .sp -1
318 .IP \(bu 2.3
319 .\}
320 Behavior of
321 \fBdbus\fR
322 is similar to
323 \fBsimple\fR; however, units of this type must have the
324 \fIBusName=\fR
325 specified and the service manager will consider the unit up when the specified bus name has been acquired\&. This type is the default if
326 \fIBusName=\fR
327 is specified\&.
328 .sp
329 Service units with this option configured implicitly gain dependencies on the
330 dbus\&.socket
331 unit\&. A service unit of this type is considered to be in the activating state until the specified bus name is acquired\&. It is considered activated while the bus name is taken\&. Once the bus name is released the service is considered being no longer functional which has the effect that the service manager attempts to terminate any remaining processes belonging to the service\&. Services that drop their bus name as part of their shutdown logic thus should be prepared to receive a
332 \fBSIGTERM\fR
333 (or whichever signal is configured in
334 \fIKillSignal=\fR) as result\&.
335 .RE
336 .sp
337 .RS 4
338 .ie n \{\
339 \h'-04'\(bu\h'+03'\c
340 .\}
341 .el \{\
342 .sp -1
343 .IP \(bu 2.3
344 .\}
345 Behavior of
346 \fBnotify\fR
347 is similar to
348 \fBexec\fR; however, it is expected that the service sends a
349 "READY=1"
350 notification message via
351 \fBsd_notify\fR(3)
352 or an equivalent call when it has finished starting up\&. systemd will proceed with starting follow\-up units after this notification message has been sent\&. If this option is used,
353 \fINotifyAccess=\fR
354 (see below) should be set to open access to the notification socket provided by systemd\&. If
355 \fINotifyAccess=\fR
356 is missing or set to
357 \fBnone\fR, it will be forcibly set to
358 \fBmain\fR\&.
359 .sp
360 If the service supports reloading, and uses a signal to start the reload, using
361 \fBnotify\-reload\fR
362 instead is recommended\&.
363 .RE
364 .sp
365 .RS 4
366 .ie n \{\
367 \h'-04'\(bu\h'+03'\c
368 .\}
369 .el \{\
370 .sp -1
371 .IP \(bu 2.3
372 .\}
373 Behavior of
374 \fBnotify\-reload\fR
375 is similar to
376 \fBnotify\fR, with one difference: the
377 \fBSIGHUP\fR
378 UNIX process signal is sent to the service\*(Aqs main process when the service is asked to reload and the manager will wait for a notification about the reload being finished\&.
379 .sp
380 When initiating the reload process the service is expected to reply with a notification message via
381 \fBsd_notify\fR(3)
382 that contains the
383 "RELOADING=1"
384 field in combination with
385 "MONOTONIC_USEC="
386 set to the current monotonic time (i\&.e\&.
387 \fBCLOCK_MONOTONIC\fR
388 in
389 \fBclock_gettime\fR(2)) in μs, formatted as decimal string\&. Once reloading is complete another notification message must be sent, containing
390 "READY=1"\&. Using this service type and implementing this reload protocol is an efficient alternative to providing an
391 \fIExecReload=\fR
392 command for reloading of the service\*(Aqs configuration\&.
393 .sp
394 The signal to send can be tweaked via
395 \fIReloadSignal=\fR, see below\&.
396 .RE
397 .sp
398 .RS 4
399 .ie n \{\
400 \h'-04'\(bu\h'+03'\c
401 .\}
402 .el \{\
403 .sp -1
404 .IP \(bu 2.3
405 .\}
406 Behavior of
407 \fBidle\fR
408 is very similar to
409 \fBsimple\fR; however, actual execution of the service program is delayed until all active jobs are dispatched\&. This may be used to avoid interleaving of output of shell services with the status output on the console\&. Note that this type is useful only to improve console output, it is not useful as a general unit ordering tool, and the effect of this service type is subject to a 5s timeout, after which the service program is invoked anyway\&.
410 .RE
411 .sp
412 It is recommended to use
413 \fIType=\fR\fBexec\fR
414 for long\-running services, as it ensures that process setup errors (e\&.g\&. errors such as a missing service executable, or missing user) are properly tracked\&. However, as this service type will not propagate the failures in the service\*(Aqs own startup code (as opposed to failures in the preparatory steps the service manager executes before
415 \fBexecve()\fR) and does not allow ordering of other units against completion of initialization of the service code itself (which for example is useful if clients need to connect to the service through some form of IPC, and the IPC channel is only established by the service itself \(em in contrast to doing this ahead of time through socket or bus activation or similar), it might not be sufficient for many cases\&. If so,
416 \fBnotify\fR,
417 \fBnotify\-reload\fR, or
418 \fBdbus\fR
419 (the latter only in case the service provides a D\-Bus interface) are the preferred options as they allow service program code to precisely schedule when to consider the service started up successfully and when to proceed with follow\-up units\&. The
420 \fBnotify\fR/\fBnotify\-reload\fR
421 service types require explicit support in the service codebase (as
422 \fBsd_notify()\fR
423 or an equivalent API needs to be invoked by the service at the appropriate time) \(em if it is not supported, then
424 \fBforking\fR
425 is an alternative: it supports the traditional heavy\-weight UNIX service start\-up protocol\&. Note that using any type other than
426 \fBsimple\fR
427 possibly delays the boot process, as the service manager needs to wait for at least some service initialization to complete\&. (Also note it is generally not recommended to use
428 \fBidle\fR
429 or
430 \fBoneshot\fR
431 for long\-running services\&.)
432 .sp
433 Note that various service settings (e\&.g\&.
434 \fIUser=\fR,
435 \fIGroup=\fR
436 through libc NSS) might result in "hidden" blocking IPC calls to other services when used\&. Sometimes it might be advisable to use the
437 \fBsimple\fR
438 service type to ensure that the service manager\*(Aqs transaction logic is not affected by such potentially slow operations and hidden dependencies, as this is the only service type where the service manager will not wait for such service execution setup operations to complete before proceeding\&.
439 .RE
440 .PP
441 \fIExitType=\fR
442 .RS 4
443 Specifies when the manager should consider the service to be finished\&. One of
444 \fBmain\fR
445 or
446 \fBcgroup\fR:
447 .sp
448 .RS 4
449 .ie n \{\
450 \h'-04'\(bu\h'+03'\c
451 .\}
452 .el \{\
453 .sp -1
454 .IP \(bu 2.3
455 .\}
456 If set to
457 \fBmain\fR
458 (the default), the service manager will consider the unit stopped when the main process, which is determined according to the
459 \fIType=\fR, exits\&. Consequently, it cannot be used with
460 \fIType=\fR\fBoneshot\fR\&.
461 .RE
462 .sp
463 .RS 4
464 .ie n \{\
465 \h'-04'\(bu\h'+03'\c
466 .\}
467 .el \{\
468 .sp -1
469 .IP \(bu 2.3
470 .\}
471 If set to
472 \fBcgroup\fR, the service will be considered running as long as at least one process in the cgroup has not exited\&.
473 .RE
474 .sp
475 It is generally recommended to use
476 \fIExitType=\fR\fBmain\fR
477 when a service has a known forking model and a main process can reliably be determined\&.
478 \fIExitType=\fR
479 \fBcgroup\fR
480 is meant for applications whose forking model is not known ahead of time and which might not have a specific main process\&. It is well suited for transient or automatically generated services, such as graphical applications inside of a desktop environment\&.
481 .sp
482 Added in version 250\&.
483 .RE
484 .PP
485 \fIRemainAfterExit=\fR
486 .RS 4
487 Takes a boolean value that specifies whether the service shall be considered active even when all its processes exited\&. Defaults to
488 \fBno\fR\&.
489 .RE
490 .PP
491 \fIGuessMainPID=\fR
492 .RS 4
493 Takes a boolean value that specifies whether systemd should try to guess the main PID of a service if it cannot be determined reliably\&. This option is ignored unless
494 \fBType=forking\fR
495 is set and
496 \fBPIDFile=\fR
497 is unset because for the other types or with an explicitly configured PID file, the main PID is always known\&. The guessing algorithm might come to incorrect conclusions if a daemon consists of more than one process\&. If the main PID cannot be determined, failure detection and automatic restarting of a service will not work reliably\&. Defaults to
498 \fByes\fR\&.
499 .RE
500 .PP
501 \fIPIDFile=\fR
502 .RS 4
503 Takes a path referring to the PID file of the service\&. Usage of this option is recommended for services where
504 \fIType=\fR
505 is set to
506 \fBforking\fR\&. The path specified typically points to a file below
507 /run/\&. If a relative path is specified for system service, then it is hence prefixed with
508 /run/, and prefixed with
509 $XDG_RUNTIME_DIR
510 if specified in a user service\&. The service manager will read the PID of the main process of the service from this file after start\-up of the service\&. The service manager will not write to the file configured here, although it will remove the file after the service has shut down if it still exists\&. The PID file does not need to be owned by a privileged user, but if it is owned by an unprivileged user additional safety restrictions are enforced: the file may not be a symlink to a file owned by a different user (neither directly nor indirectly), and the PID file must refer to a process already belonging to the service\&.
511 .sp
512 Note that PID files should be avoided in modern projects\&. Use
513 \fBType=notify\fR,
514 \fBType=notify\-reload\fR
515 or
516 \fBType=simple\fR
517 where possible, which does not require use of PID files to determine the main process of a service and avoids needless forking\&.
518 .RE
519 .PP
520 \fIBusName=\fR
521 .RS 4
522 Takes a D\-Bus destination name that this service shall use\&. This option is mandatory for services where
523 \fIType=\fR
524 is set to
525 \fBdbus\fR\&. It is recommended to always set this property if known to make it easy to map the service name to the D\-Bus destination\&. In particular,
526 \fBsystemctl service\-log\-level/service\-log\-target\fR
527 verbs make use of this\&.
528 .RE
529 .PP
530 \fIExecStart=\fR
531 .RS 4
532 Commands that are executed when this service is started\&.
533 .sp
534 Unless
535 \fIType=\fR
536 is
537 \fBoneshot\fR, exactly one command must be given\&. When
538 \fIType=oneshot\fR
539 is used, this setting may be used multiple times to define multiple commands to execute\&. If the empty string is assigned to this option, the list of commands to start is reset, prior assignments of this option will have no effect\&. If no
540 \fIExecStart=\fR
541 is specified, then the service must have
542 \fIRemainAfterExit=yes\fR
543 and at least one
544 \fIExecStop=\fR
545 line set\&. (Services lacking both
546 \fIExecStart=\fR
547 and
548 \fIExecStop=\fR
549 are not valid\&.)
550 .sp
551 If more than one command is configured, the commands are invoked sequentially in the order they appear in the unit file\&. If one of the commands fails (and is not prefixed with
552 "\-"), other lines are not executed, and the unit is considered failed\&.
553 .sp
554 Unless
555 \fIType=forking\fR
556 is set, the process started via this command line will be considered the main process of the daemon\&.
557 .RE
558 .PP
559 \fIExecStartPre=\fR, \fIExecStartPost=\fR
560 .RS 4
561 Additional commands that are executed before or after the command in
562 \fIExecStart=\fR, respectively\&. Syntax is the same as for
563 \fIExecStart=\fR\&. Multiple command lines are allowed, regardless of the service type (i\&.e\&.
564 \fIType=\fR), and the commands are executed one after the other, serially\&.
565 .sp
566 If any of those commands (not prefixed with
567 "\-") fail, the rest are not executed and the unit is considered failed\&.
568 .sp
569 \fIExecStart=\fR
570 commands are only run after all
571 \fIExecStartPre=\fR
572 commands that were not prefixed with a
573 "\-"
574 exit successfully\&.
575 .sp
576 \fIExecStartPost=\fR
577 commands are only run after the commands specified in
578 \fIExecStart=\fR
579 have been invoked successfully, as determined by
580 \fIType=\fR
581 (i\&.e\&. the process has been started for
582 \fIType=simple\fR
583 or
584 \fIType=idle\fR, the last
585 \fIExecStart=\fR
586 process exited successfully for
587 \fIType=oneshot\fR, the initial process exited successfully for
588 \fIType=forking\fR,
589 "READY=1"
590 is sent for
591 \fIType=notify\fR/\fIType=notify\-reload\fR, or the
592 \fIBusName=\fR
593 has been taken for
594 \fIType=dbus\fR)\&.
595 .sp
596 Note that
597 \fIExecStartPre=\fR
598 may not be used to start long\-running processes\&. All processes forked off by processes invoked via
599 \fIExecStartPre=\fR
600 will be killed before the next service process is run\&.
601 .sp
602 Note that if any of the commands specified in
603 \fIExecStartPre=\fR,
604 \fIExecStart=\fR, or
605 \fIExecStartPost=\fR
606 fail (and are not prefixed with
607 "\-", see above) or time out before the service is fully up, execution continues with commands specified in
608 \fIExecStopPost=\fR, the commands in
609 \fIExecStop=\fR
610 are skipped\&.
611 .sp
612 Note that the execution of
613 \fIExecStartPost=\fR
614 is taken into account for the purpose of
615 \fIBefore=\fR/\fIAfter=\fR
616 ordering constraints\&.
617 .RE
618 .PP
619 \fIExecCondition=\fR
620 .RS 4
621 Optional commands that are executed before the commands in
622 \fIExecStartPre=\fR\&. Syntax is the same as for
623 \fIExecStart=\fR\&. Multiple command lines are allowed, regardless of the service type (i\&.e\&.
624 \fIType=\fR), and the commands are executed one after the other, serially\&.
625 .sp
626 The behavior is like an
627 \fIExecStartPre=\fR
628 and condition check hybrid: when an
629 \fIExecCondition=\fR
630 command exits with exit code 1 through 254 (inclusive), the remaining commands are skipped and the unit is
631 \fInot\fR
632 marked as failed\&. However, if an
633 \fIExecCondition=\fR
634 command exits with 255 or abnormally (e\&.g\&. timeout, killed by a signal, etc\&.), the unit will be considered failed (and remaining commands will be skipped)\&. Exit code of 0 or those matching
635 \fISuccessExitStatus=\fR
636 will continue execution to the next commands\&.
637 .sp
638 The same recommendations about not running long\-running processes in
639 \fIExecStartPre=\fR
640 also applies to
641 \fIExecCondition=\fR\&.
642 \fIExecCondition=\fR
643 will also run the commands in
644 \fIExecStopPost=\fR, as part of stopping the service, in the case of any non\-zero or abnormal exits, like the ones described above\&.
645 .sp
646 Added in version 243\&.
647 .RE
648 .PP
649 \fIExecReload=\fR
650 .RS 4
651 Commands to execute to trigger a configuration reload in the service\&. This setting may take multiple command lines, following the same scheme as described for
652 \fIExecStart=\fR
653 above\&. Use of this setting is optional\&. Specifier and environment variable substitution is supported here following the same scheme as for
654 \fIExecStart=\fR\&.
655 .sp
656 One additional, special environment variable is set: if known,
657 \fI$MAINPID\fR
658 is set to the main process of the daemon, and may be used for command lines like the following:
659 .sp
660 .if n \{\
661 .RS 4
662 .\}
663 .nf
664 ExecReload=kill \-HUP $MAINPID
665 .fi
666 .if n \{\
667 .RE
668 .\}
669 .sp
670 Note however that reloading a daemon by enqueuing a signal without completion notification (as is the case with the example line above) is usually not a good choice, because this is an asynchronous operation and hence not suitable when ordering reloads of multiple services against each other\&. It is thus strongly recommended to either use
671 \fIType=notify\-reload\fR, or to set
672 \fIExecReload=\fR
673 to a command that not only triggers a configuration reload of the daemon, but also synchronously waits for it to complete\&. For example,
674 \fBdbus-broker\fR(1)
675 uses the following:
676 .sp
677 .if n \{\
678 .RS 4
679 .\}
680 .nf
681 ExecReload=busctl call org\&.freedesktop\&.DBus \e
682 /org/freedesktop/DBus org\&.freedesktop\&.DBus \e
683 ReloadConfig
684 .fi
685 .if n \{\
686 .RE
687 .\}
688 .sp
689 This setting can be combined with
690 \fIType=notify\-reload\fR, in which case the service main process is signaled after all specified command lines finish execution\&. Specially, if
691 "RELOADING=1"
692 notification is received before
693 \fIExecReload=\fR
694 completes, the signaling is skipped and the service manager immediately starts listening for
695 "READY=1"\&.
696 .RE
697 .PP
698 \fIExecReloadPost=\fR
699 .RS 4
700 Commands to execute after a successful reload operation\&. Syntax for this setting is exactly the same as
701 \fIExecReload=\fR\&.
702 .sp
703 Added in version 259\&.
704 .RE
705 .PP
706 \fIExecStop=\fR
707 .RS 4
708 Commands to execute to stop the service started via
709 \fIExecStart=\fR\&. This argument takes multiple command lines, following the same scheme as described for
710 \fIExecStart=\fR
711 above\&. Use of this setting is optional\&. After the commands configured in this option are run, it is implied that the service is stopped, and any processes remaining for it are terminated according to the
712 \fIKillMode=\fR
713 setting (see
714 \fBsystemd.kill\fR(5))\&. If this option is not specified, the process is terminated by sending the signal specified in
715 \fIKillSignal=\fR
716 or
717 \fIRestartKillSignal=\fR
718 when service stop is requested\&. Specifier and environment variable substitution is supported (including
719 \fI$MAINPID\fR, see above)\&.
720 .sp
721 Note that it is usually not sufficient to specify a command for this setting that only asks the service to terminate (for example, by sending some form of termination signal to it), but does not wait for it to do so\&. Since the remaining processes of the services are killed according to
722 \fIKillMode=\fR
723 and
724 \fIKillSignal=\fR
725 or
726 \fIRestartKillSignal=\fR
727 as described above immediately after the command exited, this may not result in a clean stop\&. The specified command should hence be a synchronous operation, not an asynchronous one\&.
728 .sp
729 Note that the commands specified in
730 \fIExecStop=\fR
731 are only executed when the service started successfully first\&. They are not invoked if the service was never started at all, or in case its start\-up failed, for example because any of the commands specified in
732 \fIExecStart=\fR,
733 \fIExecStartPre=\fR
734 or
735 \fIExecStartPost=\fR
736 failed (and were not prefixed with
737 "\-", see above) or timed out\&. Use
738 \fIExecStopPost=\fR
739 to invoke commands when a service failed to start up correctly and is shut down again\&. Also note that the stop operation is always performed if the service started successfully, even if the processes in the service terminated on their own or were killed\&. The stop commands must be prepared to deal with that case\&.
740 \fI$MAINPID\fR
741 will be unset if systemd knows that the main process exited by the time the stop commands are called\&.
742 .sp
743 Service restart requests are implemented as stop operations followed by start operations\&. This means that
744 \fIExecStop=\fR
745 and
746 \fIExecStopPost=\fR
747 are executed during a service restart operation\&.
748 .sp
749 It is recommended to use this setting for commands that communicate with the service requesting clean termination\&. For post\-mortem clean\-up steps use
750 \fIExecStopPost=\fR
751 instead\&.
752 .RE
753 .PP
754 \fIExecStopPost=\fR
755 .RS 4
756 Additional commands that are executed after the service is stopped\&. This includes cases where the commands configured in
757 \fIExecStop=\fR
758 were used, where the service does not have any
759 \fIExecStop=\fR
760 defined, or where the service exited unexpectedly\&. This argument takes multiple command lines, following the same scheme as described for
761 \fIExecStart=\fR\&. Use of these settings is optional\&. Specifier and environment variable substitution is supported\&. Note that \(en unlike
762 \fIExecStop=\fR
763 \(en commands specified with this setting are invoked when a service failed to start up correctly and is shut down again\&.
764 .sp
765 It is recommended to use this setting for clean\-up operations that shall be executed even when the service failed to start up correctly\&. Commands configured with this setting need to be able to operate even if the service failed starting up half\-way and left incompletely initialized data around\&. As the service\*(Aqs processes have likely exited already when the commands specified with this setting are executed they should not attempt to communicate with them\&.
766 .sp
767 Note that all commands that are configured with this setting are invoked with the result code of the service, as well as the main process\*(Aq exit code and status, set in the
768 \fI$SERVICE_RESULT\fR,
769 \fI$EXIT_CODE\fR
770 and
771 \fI$EXIT_STATUS\fR
772 environment variables, see
773 \fBsystemd.exec\fR(5)
774 for details\&.
775 .sp
776 Note that the execution of
777 \fIExecStopPost=\fR
778 is taken into account for the purpose of
779 \fIBefore=\fR/\fIAfter=\fR
780 ordering constraints\&.
781 .RE
782 .PP
783 \fIRestartSec=\fR
784 .RS 4
785 Configures the time to sleep before restarting a service (as configured with
786 \fIRestart=\fR)\&. Takes a unit\-less value in seconds, or a time span value such as "5min 20s"\&. Defaults to 100ms\&.
787 .RE
788 .PP
789 \fIRestartSteps=\fR
790 .RS 4
791 Configures the number of exponential steps to take to increase the interval of auto\-restarts from
792 \fIRestartSec=\fR
793 to
794 \fIRestartMaxDelaySec=\fR\&. Takes a positive integer or 0 to disable it\&. Defaults to 0\&.
795 \fIHint:\fR
796 values between 3 and 5 are good choices when exponential backoff is desired\&.
797 .sp
798 Example:
799 .sp
800 .if n \{\
801 .RS 4
802 .\}
803 .nf
804 RestartSec=10s
805 RestartSteps=4
806 RestartMaxDelaySec=160s
807 .fi
808 .if n \{\
809 .RE
810 .\}
811 .sp
812 This will produce the following restart intervals: 10s, 20s, 40s, 80s, 160s, 160s, 160s, etc\&. Notice the geometric interpolation and the resulting constant ratio between intervals; here it is 2\&. The formula for the
813 \fIratio\fR
814 is
815 (\fIRestartMaxDelaySec\fR / \fIRestartSec\fR)^(1 / \fIRestartSteps\fR)\&. A (repeating) delay equal to
816 \fIRestartMaxDelaySec=\fR
817 is always reached after
818 \fIRestartSteps\fR + 1
819 steps\&.
820 .sp
821 This setting is effective only if
822 \fIRestartMaxDelaySec=\fR
823 is also set and
824 \fIRestartSec=\fR
825 is not zero\&.
826 .sp
827 Added in version 254\&.
828 .RE
829 .PP
830 \fIRestartMaxDelaySec=\fR
831 .RS 4
832 Configures the longest time to sleep before restarting a service as the interval goes up with
833 \fIRestartSteps=\fR\&. Takes a value in the same format as
834 \fIRestartSec=\fR, or
835 "infinity"
836 to disable the setting\&. Defaults to
837 "infinity"\&.
838 .sp
839 This setting is effective only if
840 \fIRestartSteps=\fR
841 is also set and
842 \fIRestartSec=\fR
843 is not zero\&.
844 .sp
845 Added in version 254\&.
846 .RE
847 .PP
848 \fITimeoutStartSec=\fR
849 .RS 4
850 Configures the time to wait for start\-up\&. If a daemon service does not signal start\-up completion within the configured time, the service will be considered failed and will be shut down again\&. The precise action depends on the
851 \fITimeoutStartFailureMode=\fR
852 option\&. Takes a unit\-less value in seconds, or a time span value such as "5min 20s"\&. Pass
853 "infinity"
854 to disable the timeout logic\&. Defaults to
855 \fIDefaultTimeoutStartSec=\fR
856 set in the manager, except when
857 \fIType=oneshot\fR
858 is used, in which case the timeout is disabled by default (see
859 \fBsystemd-system.conf\fR(5))\&.
860 .sp
861 If a service of
862 \fIType=notify\fR/\fIType=notify\-reload\fR
863 sends
864 "EXTEND_TIMEOUT_USEC=\&...", this may cause the start time to be extended beyond
865 \fITimeoutStartSec=\fR\&. The first receipt of this message must occur before
866 \fITimeoutStartSec=\fR
867 is exceeded, and once the start time has extended beyond
868 \fITimeoutStartSec=\fR, the service manager will allow the service to continue to start, provided the service repeats
869 "EXTEND_TIMEOUT_USEC=\&..."
870 within the interval specified until the service startup status is finished by
871 "READY=1"\&. (see
872 \fBsd_notify\fR(3))\&.
873 .sp
874 Note that the start timeout is also applied to service reloads, regardless of whether implemented through
875 \fIExecReload=\fR
876 or via the reload logic enabled via
877 \fIType=notify\-reload\fR\&. If the reload does not complete within the configured time, the reload will be considered failed and the service will continue running with the old configuration\&. This will not affect the running service, but will be logged and will cause e\&.g\&.
878 \fBsystemctl reload\fR
879 to fail\&.
880 .sp
881 Added in version 188\&.
882 .RE
883 .PP
884 \fITimeoutStopSec=\fR
885 .RS 4
886 This option serves two purposes\&. First, it configures the time to wait for each
887 \fIExecStop=\fR
888 command\&. If any of them times out, subsequent
889 \fIExecStop=\fR
890 commands are skipped and the service will be terminated by
891 \fBSIGTERM\fR\&. If no
892 \fIExecStop=\fR
893 commands are specified, the service gets the
894 \fBSIGTERM\fR
895 immediately\&. This default behavior can be changed by the
896 \fITimeoutStopFailureMode=\fR
897 option\&. Second, it configures the time to wait for the service itself to stop\&. If it does not terminate in the specified time, it will be forcibly terminated by
898 \fBSIGKILL\fR
899 (see
900 \fIKillMode=\fR
901 in
902 \fBsystemd.kill\fR(5))\&. Takes a unit\-less value in seconds, or a time span value such as "5min 20s"\&. Pass
903 "infinity"
904 to disable the timeout logic\&. Defaults to
905 \fIDefaultTimeoutStopSec=\fR
906 from the manager configuration file (see
907 \fBsystemd-system.conf\fR(5))\&.
908 .sp
909 If a service of
910 \fIType=notify\fR/\fIType=notify\-reload\fR
911 sends
912 "EXTEND_TIMEOUT_USEC=\&...", this may cause the stop time to be extended beyond
913 \fITimeoutStopSec=\fR\&. The first receipt of this message must occur before
914 \fITimeoutStopSec=\fR
915 is exceeded, and once the stop time has extended beyond
916 \fITimeoutStopSec=\fR, the service manager will allow the service to continue to stop, provided the service repeats
917 "EXTEND_TIMEOUT_USEC=\&..."
918 within the interval specified, or terminates itself (see
919 \fBsd_notify\fR(3))\&.
920 .sp
921 Added in version 188\&.
922 .RE
923 .PP
924 \fITimeoutAbortSec=\fR
925 .RS 4
926 This option configures the time to wait for the service to terminate when it was aborted due to a watchdog timeout (see
927 \fIWatchdogSec=\fR)\&. If the service has a short
928 \fITimeoutStopSec=\fR
929 this option can be used to give the system more time to write a core dump of the service\&. Upon expiration the service will be forcibly terminated by
930 \fBSIGKILL\fR
931 (see
932 \fIKillMode=\fR
933 in
934 \fBsystemd.kill\fR(5))\&. The core file will be truncated in this case\&. Use
935 \fITimeoutAbortSec=\fR
936 to set a sensible timeout for the core dumping per service that is large enough to write all expected data while also being short enough to handle the service failure in due time\&.
937 .sp
938 Takes a unit\-less value in seconds, or a time span value such as "5min 20s"\&. Pass an empty value to skip the dedicated watchdog abort timeout handling and fall back
939 \fITimeoutStopSec=\fR\&. Pass
940 "infinity"
941 to disable the timeout logic\&. Defaults to
942 \fIDefaultTimeoutAbortSec=\fR
943 from the manager configuration file (see
944 \fBsystemd-system.conf\fR(5))\&.
945 .sp
946 If a service of
947 \fIType=notify\fR/\fIType=notify\-reload\fR
948 handles
949 \fBSIGABRT\fR
950 itself (instead of relying on the kernel to write a core dump) it can send
951 "EXTEND_TIMEOUT_USEC=\&..."
952 to extended the abort time beyond
953 \fITimeoutAbortSec=\fR\&. The first receipt of this message must occur before
954 \fITimeoutAbortSec=\fR
955 is exceeded, and once the abort time has extended beyond
956 \fITimeoutAbortSec=\fR, the service manager will allow the service to continue to abort, provided the service repeats
957 "EXTEND_TIMEOUT_USEC=\&..."
958 within the interval specified, or terminates itself (see
959 \fBsd_notify\fR(3))\&.
960 .sp
961 Added in version 243\&.
962 .RE
963 .PP
964 \fITimeoutSec=\fR
965 .RS 4
966 A shorthand for configuring both
967 \fITimeoutStartSec=\fR
968 and
969 \fITimeoutStopSec=\fR
970 to the specified value\&.
971 .RE
972 .PP
973 \fITimeoutStartFailureMode=\fR, \fITimeoutStopFailureMode=\fR
974 .RS 4
975 These options configure the action that is taken in case a daemon service does not signal start\-up within its configured
976 \fITimeoutStartSec=\fR, respectively if it does not stop within
977 \fITimeoutStopSec=\fR\&. Takes one of
978 \fBterminate\fR,
979 \fBabort\fR
980 and
981 \fBkill\fR\&. Both options default to
982 \fBterminate\fR\&.
983 .sp
984 If
985 \fBterminate\fR
986 is set the service will be gracefully terminated by sending the signal specified in
987 \fIKillSignal=\fR
988 (defaults to
989 \fBSIGTERM\fR, see
990 \fBsystemd.kill\fR(5))\&. If the service does not terminate the
991 \fIFinalKillSignal=\fR
992 is sent after
993 \fITimeoutStopSec=\fR\&. If
994 \fBabort\fR
995 is set,
996 \fIWatchdogSignal=\fR
997 is sent instead and
998 \fITimeoutAbortSec=\fR
999 applies before sending
1000 \fIFinalKillSignal=\fR\&. This setting may be used to analyze services that fail to start\-up or shut\-down intermittently\&. By using
1001 \fBkill\fR
1002 the service is immediately terminated by sending
1003 \fIFinalKillSignal=\fR
1004 without any further timeout\&. This setting can be used to expedite the shutdown of failing services\&.
1005 .sp
1006 Added in version 246\&.
1007 .RE
1008 .PP
1009 \fIRuntimeMaxSec=\fR
1010 .RS 4
1011 Configures a maximum time for the service to run\&. If this is used and the service has been active for longer than the specified time it is terminated and put into a failure state\&. Note that this setting does not have any effect on
1012 \fIType=oneshot\fR
1013 services, as they terminate immediately after activation completed (use
1014 \fITimeoutStartSec=\fR
1015 to limit their activation)\&. Pass
1016 "infinity"
1017 (the default) to configure no runtime limit\&.
1018 .sp
1019 If a service of
1020 \fIType=notify\fR/\fIType=notify\-reload\fR
1021 sends
1022 "EXTEND_TIMEOUT_USEC=\&...", this may cause the runtime to be extended beyond
1023 \fIRuntimeMaxSec=\fR\&. The first receipt of this message must occur before
1024 \fIRuntimeMaxSec=\fR
1025 is exceeded, and once the runtime has extended beyond
1026 \fIRuntimeMaxSec=\fR, the service manager will allow the service to continue to run, provided the service repeats
1027 "EXTEND_TIMEOUT_USEC=\&..."
1028 within the interval specified until the service shutdown is achieved by
1029 "STOPPING=1"
1030 (or termination)\&. (see
1031 \fBsd_notify\fR(3))\&.
1032 .sp
1033 Added in version 229\&.
1034 .RE
1035 .PP
1036 \fIRuntimeRandomizedExtraSec=\fR
1037 .RS 4
1038 This option modifies
1039 \fIRuntimeMaxSec=\fR
1040 by increasing the maximum runtime by an evenly distributed duration between 0 and the specified value (in seconds)\&. If
1041 \fIRuntimeMaxSec=\fR
1042 is unspecified, then this feature will be disabled\&.
1043 .sp
1044 Added in version 250\&.
1045 .RE
1046 .PP
1047 \fIWatchdogSec=\fR
1048 .RS 4
1049 Configures the watchdog timeout for a service\&. The watchdog is activated when the start\-up is completed\&. The service must call
1050 \fBsd_notify\fR(3)
1051 regularly with
1052 "WATCHDOG=1"
1053 (i\&.e\&. the "keep\-alive ping")\&. If the time between two such calls is larger than the configured time, then the service is placed in a failed state and it will be terminated with
1054 \fBSIGABRT\fR
1055 (or the signal specified by
1056 \fIWatchdogSignal=\fR)\&. By setting
1057 \fIRestart=\fR
1058 to
1059 \fBon\-failure\fR,
1060 \fBon\-watchdog\fR,
1061 \fBon\-abnormal\fR
1062 or
1063 \fBalways\fR, the service will be automatically restarted\&. The time configured here will be passed to the executed service process in the
1064 \fIWATCHDOG_USEC=\fR
1065 environment variable\&. This allows daemons to automatically enable the keep\-alive pinging logic if watchdog support is enabled for the service\&. If this option is used,
1066 \fINotifyAccess=\fR
1067 (see below) should be set to open access to the notification socket provided by systemd\&. If
1068 \fINotifyAccess=\fR
1069 is not set, it will be implicitly set to
1070 \fBmain\fR\&. Defaults to 0, which disables this feature\&. The service can check whether the service manager expects watchdog keep\-alive notifications\&. See
1071 \fBsd_watchdog_enabled\fR(3)
1072 for details\&.
1073 \fBsd_event_set_watchdog\fR(3)
1074 may be used to enable automatic watchdog notification support\&.
1075 .RE
1076 .PP
1077 \fIRestart=\fR
1078 .RS 4
1079 Configures whether the service shall be restarted when the service process exits, is killed, or a timeout is reached\&. The service process may be the main service process, but it may also be one of the processes specified with
1080 \fIExecStartPre=\fR,
1081 \fIExecStartPost=\fR,
1082 \fIExecStop=\fR,
1083 \fIExecStopPost=\fR, or
1084 \fIExecReload=\fR\&. When the death of the process is a result of systemd operation (e\&.g\&. service stop or restart), the service will not be restarted\&. Timeouts include missing the watchdog "keep\-alive ping" deadline and a service start, reload, and stop operation timeouts\&.
1085 .sp
1086 Takes one of
1087 \fBno\fR,
1088 \fBon\-success\fR,
1089 \fBon\-failure\fR,
1090 \fBon\-abnormal\fR,
1091 \fBon\-watchdog\fR,
1092 \fBon\-abort\fR, or
1093 \fBalways\fR\&. If set to
1094 \fBno\fR
1095 (the default), the service will not be restarted\&. If set to
1096 \fBon\-success\fR, it will be restarted only when the service process exits cleanly\&. In this context, a clean exit means any of the following:
1097 .sp
1098 .RS 4
1099 .ie n \{\
1100 \h'-04'\(bu\h'+03'\c
1101 .\}
1102 .el \{\
1103 .sp -1
1104 .IP \(bu 2.3
1105 .\}
1106 exit code of 0;
1107 .RE
1108 .sp
1109 .RS 4
1110 .ie n \{\
1111 \h'-04'\(bu\h'+03'\c
1112 .\}
1113 .el \{\
1114 .sp -1
1115 .IP \(bu 2.3
1116 .\}
1117 for types other than
1118 \fIType=oneshot\fR, one of the signals
1119 \fBSIGHUP\fR,
1120 \fBSIGINT\fR,
1121 \fBSIGTERM\fR, or
1122 \fBSIGPIPE\fR;
1123 .RE
1124 .sp
1125 .RS 4
1126 .ie n \{\
1127 \h'-04'\(bu\h'+03'\c
1128 .\}
1129 .el \{\
1130 .sp -1
1131 .IP \(bu 2.3
1132 .\}
1133 exit statuses and signals specified in
1134 \fISuccessExitStatus=\fR\&.
1135 .RE
1136 .sp
1137 If set to
1138 \fBon\-failure\fR, the service will be restarted when the process exits with a non\-zero exit code, is terminated by a signal (including on core dump, but excluding the aforementioned four signals), when an operation (such as service reload) times out, and when the configured watchdog timeout is triggered\&. If set to
1139 \fBon\-abnormal\fR, the service will be restarted when the process is terminated by a signal (including on core dump, excluding the aforementioned four signals), when an operation times out, or when the watchdog timeout is triggered\&. If set to
1140 \fBon\-abort\fR, the service will be restarted only if the service process exits due to an uncaught signal not specified as a clean exit status\&. If set to
1141 \fBon\-watchdog\fR, the service will be restarted only if the watchdog timeout for the service expires\&. If set to
1142 \fBalways\fR, the service will be restarted regardless of whether it exited cleanly or not, got terminated abnormally by a signal, or hit a timeout\&. Note that
1143 \fIType=oneshot\fR
1144 services will never be restarted on a clean exit status, i\&.e\&.
1145 \fBalways\fR
1146 and
1147 \fBon\-success\fR
1148 are rejected for them\&.
1149 .sp
1150 .it 1 an-trap
1151 .nr an-no-space-flag 1
1152 .nr an-break-flag 1
1153 .br
1154 .B Table\ \&1.\ \&Exit causes and the effect of the \fIRestart=\fR settings
1155 .TS
1156 allbox tab(:);
1157 lB lB lB lB lB lB lB lB.
1158 T{
1159 Restart settings/Exit causes
1160 T}:T{
1161 \fBno\fR
1162 T}:T{
1163 \fBalways\fR
1164 T}:T{
1165 \fBon\-success\fR
1166 T}:T{
1167 \fBon\-failure\fR
1168 T}:T{
1169 \fBon\-abnormal\fR
1170 T}:T{
1171 \fBon\-abort\fR
1172 T}:T{
1173 \fBon\-watchdog\fR
1174 T}
1175 .T&
1176 l l l l l l l l
1177 l l l l l l l l
1178 l l l l l l l l
1179 l l l l l l l l
1180 l l l l l l l l
1181 l l l l l l l l.
1182 T{
1183 Clean exit code or signal
1184 T}:T{
1185 \ \&
1186 T}:T{
1187 X
1188 T}:T{
1189 X
1190 T}:T{
1191 \ \&
1192 T}:T{
1193 \ \&
1194 T}:T{
1195 \ \&
1196 T}:T{
1197 \ \&
1198 T}
1199 T{
1200 Unclean exit code
1201 T}:T{
1202 \ \&
1203 T}:T{
1204 X
1205 T}:T{
1206 \ \&
1207 T}:T{
1208 X
1209 T}:T{
1210 \ \&
1211 T}:T{
1212 \ \&
1213 T}:T{
1214 \ \&
1215 T}
1216 T{
1217 Unclean signal
1218 T}:T{
1219 \ \&
1220 T}:T{
1221 X
1222 T}:T{
1223 \ \&
1224 T}:T{
1225 X
1226 T}:T{
1227 X
1228 T}:T{
1229 X
1230 T}:T{
1231 \ \&
1232 T}
1233 T{
1234 Timeout
1235 T}:T{
1236 \ \&
1237 T}:T{
1238 X
1239 T}:T{
1240 \ \&
1241 T}:T{
1242 X
1243 T}:T{
1244 X
1245 T}:T{
1246 \ \&
1247 T}:T{
1248 \ \&
1249 T}
1250 T{
1251 Watchdog
1252 T}:T{
1253 \ \&
1254 T}:T{
1255 X
1256 T}:T{
1257 \ \&
1258 T}:T{
1259 X
1260 T}:T{
1261 X
1262 T}:T{
1263 \ \&
1264 T}:T{
1265 X
1266 T}
1267 T{
1268 Termination due to OOM
1269 T}:T{
1270 \ \&
1271 T}:T{
1272 X
1273 T}:T{
1274 \ \&
1275 T}:T{
1276 X
1277 T}:T{
1278 X
1279 T}:T{
1280 \ \&
1281 T}:T{
1282 \ \&
1283 T}
1284 .TE
1285 .sp 1
1286 As exceptions to the setting above, the service will not be restarted if the exit code or signal is specified in
1287 \fIRestartPreventExitStatus=\fR
1288 (see below) or the service is stopped with
1289 \fBsystemctl stop\fR
1290 or an equivalent operation\&. Also, the services will always be restarted if the exit code or signal is specified in
1291 \fIRestartForceExitStatus=\fR
1292 (see below)\&.
1293 .sp
1294 Note that service restart is subject to unit start rate limiting configured with
1295 \fIStartLimitIntervalSec=\fR
1296 and
1297 \fIStartLimitBurst=\fR, see
1298 \fBsystemd.unit\fR(5)
1299 for details\&.
1300 .sp
1301 Setting this to
1302 \fBon\-failure\fR
1303 is the recommended choice for long\-running services, in order to increase reliability by attempting automatic recovery from errors\&. For services that shall be able to terminate on their own choice (and avoid immediate restarting),
1304 \fBon\-abnormal\fR
1305 is an alternative choice\&.
1306 .RE
1307 .PP
1308 \fIRestartMode=\fR
1309 .RS 4
1310 Takes a string value that specifies how a service should restart:
1311 .sp
1312 .RS 4
1313 .ie n \{\
1314 \h'-04'\(bu\h'+03'\c
1315 .\}
1316 .el \{\
1317 .sp -1
1318 .IP \(bu 2.3
1319 .\}
1320 If set to
1321 \fBnormal\fR
1322 (the default), the service restarts by going through a failed/inactive state\&.
1323 .sp
1324 Added in version 254\&.
1325 .RE
1326 .sp
1327 .RS 4
1328 .ie n \{\
1329 \h'-04'\(bu\h'+03'\c
1330 .\}
1331 .el \{\
1332 .sp -1
1333 .IP \(bu 2.3
1334 .\}
1335 If set to
1336 \fBdirect\fR, the service transitions to the activating state directly during auto\-restart, skipping failed/inactive state\&.
1337 \fIExecStopPost=\fR
1338 is still invoked\&.
1339 \fIOnSuccess=\fR
1340 and
1341 \fIOnFailure=\fR
1342 are skipped\&.
1343 .sp
1344 This option is useful in cases where a dependency can fail temporarily but we do not want these temporary failures to make the dependent units fail\&. Dependent units are not notified of these temporary failures\&.
1345 .sp
1346 Added in version 254\&.
1347 .RE
1348 .sp
1349 .RS 4
1350 .ie n \{\
1351 \h'-04'\(bu\h'+03'\c
1352 .\}
1353 .el \{\
1354 .sp -1
1355 .IP \(bu 2.3
1356 .\}
1357 If set to
1358 \fBdebug\fR, the service manager will log messages that are related to this unit at debug level while automated restarts are attempted, until either the service hits the rate limit or it succeeds, and the
1359 \fI$DEBUG_INVOCATION=1\fR
1360 environment variable will be set for the unit\&. This is useful to be able to get additional information when a service fails to start, without needing to proactively or permanently enable debug level logging in systemd, which is very verbose\&. This is otherwise equivalent to
1361 \fBnormal\fR
1362 mode\&.
1363 .sp
1364 Added in version 257\&.
1365 .RE
1366 .sp
1367 Added in version 254\&.
1368 .RE
1369 .PP
1370 \fISuccessExitStatus=\fR
1371 .RS 4
1372 Takes a list of exit status definitions that, when returned by the main service process, will be considered successful termination, in addition to the normal successful exit status 0 and, except for
1373 \fIType=oneshot\fR, the signals
1374 \fBSIGHUP\fR,
1375 \fBSIGINT\fR,
1376 \fBSIGTERM\fR, and
1377 \fBSIGPIPE\fR\&. Exit status definitions can be numeric termination statuses, termination status names, or termination signal names, separated by spaces\&. See the Process Exit Codes section in
1378 \fBsystemd.exec\fR(5)
1379 for a list of termination status names (for this setting only the part without the
1380 "EXIT_"
1381 or
1382 "EX_"
1383 prefix should be used)\&. See
1384 \fBsignal\fR(7)
1385 for a list of signal names\&.
1386 .sp
1387 Note that this setting does not change the mapping between numeric exit statuses and their names, i\&.e\&. regardless how this setting is used 0 will still be mapped to
1388 "SUCCESS"
1389 (and thus typically shown as
1390 "0/SUCCESS"
1391 in tool outputs) and 1 to
1392 "FAILURE"
1393 (and thus typically shown as
1394 "1/FAILURE"), and so on\&. It only controls what happens as effect of these exit statuses, and how it propagates to the state of the service as a whole\&.
1395 .sp
1396 This option may appear more than once, in which case the list of successful exit statuses is merged\&. If the empty string is assigned to this option, the list is reset, all prior assignments of this option will have no effect\&.
1397 .PP
1398 \fBExample\ \&1.\ \&A service with the \fISuccessExitStatus=\fR setting\fR
1399 .sp
1400 .if n \{\
1401 .RS 4
1402 .\}
1403 .nf
1404 SuccessExitStatus=TEMPFAIL 250 SIGKILL
1405 .fi
1406 .if n \{\
1407 .RE
1408 .\}
1409 .sp
1410 Exit status 75 (\fBTEMPFAIL\fR), 250, and the termination signal
1411 \fBSIGKILL\fR
1412 are considered clean service terminations\&.
1413
1414 Note:
1415 \fBsystemd\-analyze exit\-status\fR
1416 may be used to list exit statuses and translate between numerical status values and names\&.
1417 .sp
1418 Added in version 189\&.
1419 .RE
1420 .PP
1421 \fIRestartPreventExitStatus=\fR
1422 .RS 4
1423 Takes a list of exit status definitions that, when returned by the main service process, will prevent automatic service restarts, regardless of the restart setting configured with
1424 \fIRestart=\fR\&. Exit status definitions can be numeric termination statuses, termination status names, or termination signal names, separated by spaces\&. Defaults to the empty list, so that, by default, no exit status is excluded from the configured restart logic\&.
1425 .PP \fBExample\ \&2.\ \&A service with the \fIRestartPreventExitStatus=\fR setting\fR .sp .if n \{\ .RS 4 .\} .nf RestartPreventExitStatus=TEMPFAIL 250 SIGKILL .fi .if n \{\ .RE .\} .sp Exit status 75 (\fBTEMPFAIL\fR), 250, and the termination signal \fBSIGKILL\fR will not result in automatic service restarting\&.
1426 This option may appear more than once, in which case the list of restart\-preventing statuses is merged\&. If the empty string is assigned to this option, the list is reset and all prior assignments of this option will have no effect\&.
1427 .sp
1428 Note that this setting has no effect on processes configured via
1429 \fIExecStartPre=\fR,
1430 \fIExecStartPost=\fR,
1431 \fIExecStop=\fR,
1432 \fIExecStopPost=\fR
1433 or
1434 \fIExecReload=\fR, but only on the main service process, i\&.e\&. either the one invoked by
1435 \fIExecStart=\fR
1436 or (depending on
1437 \fIType=\fR,
1438 \fIPIDFile=\fR, \&...) the otherwise configured main process\&.
1439 .sp
1440 Added in version 189\&.
1441 .RE
1442 .PP
1443 \fIRestartForceExitStatus=\fR
1444 .RS 4
1445 Takes a list of exit status definitions that, when returned by the main service process, will force automatic service restarts, regardless of the restart setting configured with
1446 \fIRestart=\fR\&. The argument format is similar to
1447 \fIRestartPreventExitStatus=\fR\&.
1448 .sp
1449 Note that for
1450 \fIType=oneshot\fR
1451 services, a success exit status will prevent them from auto\-restarting, no matter whether the corresponding exit statuses are listed in this option or not\&.
1452 .sp
1453 Added in version 215\&.
1454 .RE
1455 .PP
1456 \fIRootDirectoryStartOnly=\fR
1457 .RS 4
1458 Takes a boolean argument\&. If true, the root directory, as configured with the
1459 \fIRootDirectory=\fR
1460 option (see
1461 \fBsystemd.exec\fR(5)
1462 for more information), is only applied to the process started with
1463 \fIExecStart=\fR, and not to the various other
1464 \fIExecStartPre=\fR,
1465 \fIExecStartPost=\fR,
1466 \fIExecReload=\fR,
1467 \fIExecReloadPost=\fR,
1468 \fIExecStop=\fR, and
1469 \fIExecStopPost=\fR
1470 commands\&. If false, the setting is applied to all configured commands the same way\&. Defaults to false\&.
1471 .RE
1472 .PP
1473 \fINonBlocking=\fR
1474 .RS 4
1475 Set the
1476 \fBO_NONBLOCK\fR
1477 flag for all file descriptors passed via socket\-based activation\&. If true, all file descriptors >= 3 (i\&.e\&. all except stdin, stdout, stderr), excluding those passed in via the file descriptor storage logic (see
1478 \fIFileDescriptorStoreMax=\fR
1479 for details), will have the
1480 \fBO_NONBLOCK\fR
1481 flag set and hence are in non\-blocking mode\&. This option is only useful in conjunction with a socket unit, as described in
1482 \fBsystemd.socket\fR(5)
1483 and has no effect on file descriptors which were previously saved in the file\-descriptor store for example\&. Defaults to false\&.
1484 .sp
1485 Note that if the same socket unit is configured to be passed to multiple service units (via the
1486 \fISockets=\fR
1487 setting, see below), and these services have different
1488 \fINonBlocking=\fR
1489 configurations, the precise state of
1490 \fBO_NONBLOCK\fR
1491 depends on the order in which these services are invoked, and will possibly change after service code already took possession of the socket file descriptor, simply because the
1492 \fBO_NONBLOCK\fR
1493 state of a socket is shared by all file descriptors referencing it\&. Hence it is essential that all services sharing the same socket use the same
1494 \fINonBlocking=\fR
1495 configuration, and do not change the flag in service code either\&.
1496 .RE
1497 .PP
1498 \fINotifyAccess=\fR
1499 .RS 4
1500 Controls access to the service status notification socket, as accessible via the
1501 \fBsd_notify\fR(3)
1502 call\&. Takes one of
1503 \fBnone\fR
1504 (the default),
1505 \fBmain\fR,
1506 \fBexec\fR
1507 or
1508 \fBall\fR\&. If
1509 \fBnone\fR, no daemon status updates are accepted from the service processes, all status update messages are ignored\&. If
1510 \fBmain\fR, only service updates sent from the main process of the service are accepted\&. If
1511 \fBexec\fR, only service updates sent from any of the main or control processes originating from one of the
1512 \fIExec*=\fR
1513 commands are accepted\&. If
1514 \fBall\fR, all services updates from all members of the service\*(Aqs control group are accepted\&. This option should be set to open access to the notification socket when using
1515 \fIType=notify\fR/\fIType=notify\-reload\fR
1516 or
1517 \fIWatchdogSec=\fR
1518 (see above)\&. If those options are used but
1519 \fINotifyAccess=\fR
1520 is not configured, it will be implicitly set to
1521 \fBmain\fR\&.
1522 .sp
1523 Note that
1524 \fBsd_notify()\fR
1525 notifications may be attributed to units correctly only if either the sending process is still around at the time PID 1 processes the message, or if the sending process is explicitly runtime\-tracked by the service manager\&. The latter is the case if the service manager originally forked off the process, i\&.e\&. on all processes that match
1526 \fBmain\fR
1527 or
1528 \fBexec\fR\&. Conversely, if an auxiliary process of the unit sends an
1529 \fBsd_notify()\fR
1530 message and immediately exits, the service manager might not be able to properly attribute the message to the unit, and thus will ignore it, even if
1531 \fINotifyAccess=\fR\fBall\fR
1532 is set for it\&.
1533 .sp
1534 Hence, to eliminate all race conditions involving lookup of the client\*(Aqs unit and attribution of notifications to units correctly,
1535 \fBsd_notify_barrier()\fR
1536 may be used\&. This call acts as a synchronization point and ensures all notifications sent before this call have been picked up by the service manager when it returns successfully\&. Use of
1537 \fBsd_notify_barrier()\fR
1538 is needed for clients which are not invoked by the service manager, otherwise this synchronization mechanism is unnecessary for attribution of notifications to the unit\&.
1539 .RE
1540 .PP
1541 \fISockets=\fR
1542 .RS 4
1543 Specifies the name of the socket units this service shall inherit socket file descriptors from when the service is started\&. Normally, it should not be necessary to use this setting, as all socket file descriptors whose unit shares the same name as the service (subject to the different unit name suffix of course) are passed to the spawned process\&.
1544 .sp
1545 Note that the same socket file descriptors may be passed to multiple processes simultaneously\&. Also note that a different service may be activated on incoming socket traffic than the one which is ultimately configured to inherit the socket file descriptors\&. Or, in other words: the
1546 \fIService=\fR
1547 setting of
1548 \&.socket
1549 units does not have to match the inverse of the
1550 \fISockets=\fR
1551 setting of the
1552 \&.service
1553 it refers to\&.
1554 .sp
1555 This option may appear more than once, in which case the list of socket units is merged\&. Note that once set, clearing the list of sockets again (for example, by assigning the empty string to this option) is not supported\&.
1556 .RE
1557 .PP
1558 \fIFileDescriptorStoreMax=\fR
1559 .RS 4
1560 Configure how many file descriptors may be stored in the service manager for the service using
1561 \fBsd_pid_notify_with_fds\fR(3)\*(Aqs
1562 "FDSTORE=1"
1563 messages\&. This is useful for implementing services that can restart after an explicit request or a crash without losing state\&. Any open sockets and other file descriptors which should not be closed during the restart may be stored this way\&. Application state can either be serialized to a file in
1564 \fIRuntimeDirectory=\fR, or stored in a
1565 \fBmemfd_create\fR(2)
1566 memory file descriptor\&. Defaults to 0, i\&.e\&. no file descriptors may be stored in the service manager\&. All file descriptors passed to the service manager from a specific service are passed back to the service\*(Aqs main process on the next service restart (see
1567 \fBsd_listen_fds\fR(3)
1568 for details about the precise protocol used and the order in which the file descriptors are passed)\&. Any file descriptors passed to the service manager are automatically closed when
1569 \fBPOLLHUP\fR
1570 or
1571 \fBPOLLERR\fR
1572 is seen on them, or when the service is fully stopped and no job is queued or being executed for it (the latter can be tweaked with
1573 \fIFileDescriptorStorePreserve=\fR, see below)\&. If this option is used,
1574 \fINotifyAccess=\fR
1575 (see above) should be set to open access to the notification socket provided by systemd\&. If
1576 \fINotifyAccess=\fR
1577 is not set, it will be implicitly set to
1578 \fBmain\fR\&.
1579 .sp
1580 The
1581 \fBfdstore\fR
1582 command of
1583 \fBsystemd-analyze\fR(1)
1584 may be used to list the current contents of a service\*(Aqs file descriptor store\&.
1585 .sp
1586 Note that the service manager will only pass file descriptors contained in the file descriptor store to the service\*(Aqs own processes, never to other clients via IPC or similar\&. However, it does allow unprivileged clients to query the list of currently open file descriptors of a service\&. Sensitive data may hence be safely placed inside the referenced files, but should not be attached to the metadata (e\&.g\&. included in filenames) of the stored file descriptors\&.
1587 .sp
1588 If this option is set to a non\-zero value the
1589 \fI$FDSTORE\fR
1590 environment variable will be set for processes invoked for this service\&. See
1591 \fBsystemd.exec\fR(5)
1592 for details\&.
1593 .sp
1594 For further information on the file descriptor store see the
1595 \m[blue]\fBFile Descriptor Store\fR\m[]\&\s-2\u[1]\d\s+2
1596 overview\&.
1597 .sp
1598 Added in version 219\&.
1599 .RE
1600 .PP
1601 \fIFileDescriptorStorePreserve=\fR
1602 .RS 4
1603 Takes one of
1604 \fBno\fR,
1605 \fByes\fR,
1606 \fBrestart\fR
1607 and controls when to release the service\*(Aqs file descriptor store (i\&.e\&. when to close the contained file descriptors, if any)\&. If set to
1608 \fBno\fR
1609 the file descriptor store is automatically released when the service is stopped; if
1610 \fBrestart\fR
1611 (the default) it is kept around as long as the unit is neither inactive nor failed, or a job is queued for the service, or the service is expected to be restarted\&. If
1612 \fByes\fR
1613 the file descriptor store is kept around until the unit is removed from memory (i\&.e\&. is not referenced anymore and inactive)\&. The latter is useful to keep entries in the file descriptor store pinned until the service manager exits\&.
1614 .sp
1615 Use
1616 \fBsystemctl clean \-\-what=fdstore \&...\fR
1617 to release the file descriptor store explicitly\&.
1618 .sp
1619 Added in version 254\&.
1620 .RE
1621 .PP
1622 \fIUSBFunctionDescriptors=\fR
1623 .RS 4
1624 Configure the location of a file containing
1625 \m[blue]\fBUSB FunctionFS\fR\m[]\&\s-2\u[2]\d\s+2
1626 descriptors, for implementation of USB gadget functions\&. This is used only in conjunction with a socket unit with
1627 \fIListenUSBFunction=\fR
1628 configured\&. The contents of this file are written to the
1629 ep0
1630 file after it is opened\&.
1631 .sp
1632 Added in version 227\&.
1633 .RE
1634 .PP
1635 \fIUSBFunctionStrings=\fR
1636 .RS 4
1637 Configure the location of a file containing USB FunctionFS strings\&. Behavior is similar to
1638 \fIUSBFunctionDescriptors=\fR
1639 above\&.
1640 .sp
1641 Added in version 227\&.
1642 .RE
1643 .PP
1644 \fIOOMPolicy=\fR
1645 .RS 4
1646 Configure the out\-of\-memory (OOM) killing policy for the kernel and the userspace OOM killer
1647 \fBsystemd-oomd.service\fR(8)\&. On Linux, when memory becomes scarce to the point that the kernel has trouble allocating memory for itself, it might decide to kill a running process in order to free up memory and reduce memory pressure\&. Note that
1648 systemd\-oomd\&.service
1649 is a more flexible solution that aims to prevent out\-of\-memory situations for the userspace too, not just the kernel, by attempting to terminate services earlier, before the kernel would have to act\&.
1650 .sp
1651 This setting takes one of
1652 \fBcontinue\fR,
1653 \fBstop\fR
1654 or
1655 \fBkill\fR\&. If set to
1656 \fBcontinue\fR
1657 and a process in the unit is killed by the OOM killer, this is logged but the unit continues running\&. If set to
1658 \fBstop\fR
1659 the event is logged and the unit\*(Aqs processes are terminated cleanly by the service manager\&. If set to
1660 \fBkill\fR
1661 and one of the unit\*(Aqs processes is killed by the OOM killer the kernel is instructed to kill all remaining processes of the unit too, by setting the
1662 memory\&.oom\&.group
1663 attribute to
1664 \fB1\fR; also see kernel page
1665 \m[blue]\fBControl Group v2\fR\m[]\&\s-2\u[3]\d\s+2\&. In case of both
1666 \fBstop\fR
1667 and
1668 \fBkill\fR, the service ultimately ends up in the
1669 \fBoom\-kill\fR
1670 failed state after which
1671 \fIRestart=\fR
1672 may apply\&.
1673 .sp
1674 Defaults to the setting
1675 \fIDefaultOOMPolicy=\fR
1676 in
1677 \fBsystemd-system.conf\fR(5)
1678 is set to, except for units where
1679 \fIDelegate=\fR
1680 is turned on, where it defaults to
1681 \fBcontinue\fR\&.
1682 .sp
1683 Use the
1684 \fIOOMScoreAdjust=\fR
1685 setting to configure whether processes of the unit shall be considered preferred or less preferred candidates for process termination by the Linux OOM killer logic\&. See
1686 \fBsystemd.exec\fR(5)
1687 for details\&.
1688 .sp
1689 This setting also applies to
1690 \fBsystemd-oomd.service\fR(8)\&. Similarly to the kernel OOM kills performed by the kernel, this setting determines the state of the unit after
1691 \fBsystemd\-oomd\fR
1692 kills a cgroup associated with it\&.
1693 .sp
1694 Added in version 243\&.
1695 .RE
1696 .PP
1697 \fIOpenFile=\fR
1698 .RS 4
1699 Takes an argument of the form
1700 "path[\fI:fd\-name:options\fR]", where:
1701 .sp
1702 .RS 4
1703 .ie n \{\
1704 \h'-04'\(bu\h'+03'\c
1705 .\}
1706 .el \{\
1707 .sp -1
1708 .IP \(bu 2.3
1709 .\}
1710 "path"
1711 is a path to a file or an
1712 \fBAF_UNIX\fR
1713 socket in the file system;
1714 .RE
1715 .sp
1716 .RS 4
1717 .ie n \{\
1718 \h'-04'\(bu\h'+03'\c
1719 .\}
1720 .el \{\
1721 .sp -1
1722 .IP \(bu 2.3
1723 .\}
1724 "fd\-name"
1725 is a name that will be associated with the file descriptor; the name may contain any ASCII character, but must exclude control characters and ":", and must be at most 255 characters in length; it is optional and, if not provided, defaults to the file name;
1726 .RE
1727 .sp
1728 .RS 4
1729 .ie n \{\
1730 \h'-04'\(bu\h'+03'\c
1731 .\}
1732 .el \{\
1733 .sp -1
1734 .IP \(bu 2.3
1735 .\}
1736 "options"
1737 is a comma\-separated list of access options; possible values are
1738 "read\-only",
1739 "append",
1740 "truncate",
1741 "graceful"; if not specified, files will be opened in
1742 \fBrw\fR
1743 mode; if
1744 "graceful"
1745 is specified, errors during file/socket opening are ignored\&. Specifying the same option several times is treated as an error\&.
1746 .RE
1747 .sp
1748 The file or socket is opened by the service manager and the file descriptor is passed to the service\&. If the path is a socket, we call
1749 \fBconnect()\fR
1750 on it\&. See
1751 \fBsd_listen_fds\fR(3)
1752 for more details on how to retrieve these file descriptors\&.
1753 .sp
1754 This setting is useful to allow services to access files/sockets that they cannot access themselves (due to running in a separate mount namespace, not having privileges, \&.\&.\&.)\&.
1755 .sp
1756 This setting can be specified multiple times, in which case all the specified paths are opened and the file descriptors passed to the service\&. If the empty string is assigned, the entire list of open files defined prior to this is reset\&.
1757 .sp
1758 Added in version 253\&.
1759 .RE
1760 .PP
1761 \fIReloadSignal=\fR
1762 .RS 4
1763 Configures the UNIX process signal to send to the service\*(Aqs main process when asked to reload the service\*(Aqs configuration\&. Defaults to
1764 \fBSIGHUP\fR\&. This option has no effect unless
1765 \fIType=\fR\fBnotify\-reload\fR
1766 is used, see above\&.
1767 .sp
1768 Added in version 253\&.
1769 .RE
1770 .PP
1771 Check
1772 \fBsystemd.unit\fR(5),
1773 \fBsystemd.exec\fR(5), and
1774 \fBsystemd.kill\fR(5)
1775 for more settings\&.
1776 .SH "COMMAND LINES"
1777 .PP
1778 This section describes command line parsing and variable and specifier substitutions for
1779 \fIExecStart=\fR,
1780 \fIExecStartPre=\fR,
1781 \fIExecStartPost=\fR,
1782 \fIExecReload=\fR,
1783 \fIExecStop=\fR,
1784 \fIExecStopPost=\fR, and
1785 \fIExecCondition=\fR
1786 options\&.
1787 .PP
1788 Multiple command lines may be specified by using the relevant setting multiple times\&.
1789 .PP
1790 Each command line is unquoted using the rules described in "Quoting" section in
1791 \fBsystemd.syntax\fR(7)\&. The first item becomes the command to execute, and the subsequent items the arguments\&.
1792 .PP
1793 This syntax is inspired by shell syntax, but only the meta\-characters and expansions described in the following paragraphs are understood, and the expansion of variables is different\&. Specifically, redirection using
1794 "<",
1795 "<<",
1796 ">", and
1797 ">>", pipes using
1798 "|", running programs in the background using
1799 "&", and
1800 \fIother elements of shell syntax are not supported\fR\&.
1801 .PP
1802 The command to execute may contain spaces, but control characters are not allowed\&.
1803 .PP
1804 Each command may be prefixed with a number of special characters:
1805 .sp
1806 .it 1 an-trap
1807 .nr an-no-space-flag 1
1808 .nr an-break-flag 1
1809 .br
1810 .B Table\ \&2.\ \&Special executable prefixes
1811 .TS
1812 allbox tab(:);
1813 lB lB.
1814 T{
1815 Prefix
1816 T}:T{
1817 Effect
1818 T}
1819 .T&
1820 l l
1821 l l
1822 l l
1823 l l
1824 l l
1825 l l.
1826 T{
1827 "@"
1828 T}:T{
1829 If the executable path is prefixed with "@", the second specified token will be passed as \fBargv[0]\fR to the executed process (instead of the actual filename), followed by the further arguments specified, unless "|" is also specified, in which case it enables login shell semantics for the shell spawned by prefixing "\-" to \fBargv[0]\fR\&.
1830 T}
1831 T{
1832 "\-"
1833 T}:T{
1834 If the executable path is prefixed with "\-", an exit code of the command normally considered a failure (i\&.e\&. non\-zero exit status or abnormal exit due to signal) is recorded, but has no further effect and is considered equivalent to success\&.
1835 T}
1836 T{
1837 ":"
1838 T}:T{
1839 If the executable path is prefixed with ":", environment variable substitution (as described below this table) is not applied\&.
1840 T}
1841 T{
1842 "+"
1843 T}:T{
1844 If the executable path is prefixed with "+" then the process is executed with full privileges\&. In this mode privilege restrictions configured with \fIUser=\fR, \fIGroup=\fR, \fICapabilityBoundingSet=\fR or the various file system namespacing options (such as \fIPrivateDevices=\fR, \fIPrivateTmp=\fR) are not applied to the invoked command line (but still affect any other \fIExecStart=\fR, \fIExecStop=\fR, \&... lines)\&. However, note that this will not bypass options that apply to the whole control group, such as \fIDevicePolicy=\fR, see \fBsystemd.resource-control\fR(5) for the full list\&.
1845 T}
1846 T{
1847 "!"
1848 T}:T{
1849 Similar to the "+" character discussed above this permits invoking command lines with elevated privileges\&. However, unlike "+" the "!" character exclusively alters the effect of \fIUser=\fR, \fIGroup=\fR and \fISupplementaryGroups=\fR, i\&.e\&. only the stanzas that affect user and group credentials\&. Note that this setting may be combined with \fIDynamicUser=\fR, in which case a dynamic user/group pair is allocated before the command is invoked, but credential changing is left to the executed process itself\&.
1850 T}
1851 T{
1852 "|"
1853 T}:T{
1854 If "|" is specified standalone as executable path, invoke the default shell of \fIUser=\fR\&. If specified as a prefix, use the shell ("\-c") to spawn the executable\&. When "@" is used in conjunction, \fBargv[0]\fR of shell will be prefixed with "\-" to enable login shell semantics\&.
1855 T}
1856 .TE
1857 .sp 1
1858 .PP
1859 "@",
1860 "|",
1861 "\-",
1862 ":", and one of
1863 "+"/"!"
1864 may be used together and they can appear in any order\&. However,
1865 "+"
1866 and
1867 "!"
1868 may not be specified at the same time\&.
1869 .PP
1870 For each command, the first argument must be either an absolute path to an executable or a simple file name without any slashes\&. If the command is not a full (absolute) path, it will be resolved to a full path using a fixed search path determined at compilation time\&. Searched directories include
1871 /usr/local/bin/,
1872 /usr/bin/, and their
1873 sbin/
1874 counterparts (only on systems using split
1875 bin/
1876 and
1877 sbin/)\&. It is thus safe to use just the executable name in case of executables located in any of the "standard" directories, and an absolute path must be used in other cases\&. Hint: this search path may be queried using
1878 \fBsystemd\-path search\-binaries\-default\fR\&.
1879 .PP
1880 The command line accepts
1881 "%"
1882 specifiers as described in
1883 \fBsystemd.unit\fR(5)\&.
1884 .PP
1885 An argument solely consisting of
1886 ";"
1887 must be escaped, i\&.e\&. specified as
1888 "\e;"\&.
1889 .PP
1890 Basic environment variable substitution is supported\&. Use
1891 "${FOO}"
1892 as part of a word, or as a word of its own, on the command line, in which case it will be erased and replaced by the exact value of the environment variable (if any) including all whitespace it contains, always resulting in exactly a single argument\&. Use
1893 "$FOO"
1894 as a separate word on the command line, in which case it will be replaced by the value of the environment variable split at whitespace, resulting in zero or more arguments\&. For this type of expansion, quotes are respected when splitting into words, and afterwards removed\&.
1895 .PP
1896 Example:
1897 .sp
1898 .if n \{\
1899 .RS 4
1900 .\}
1901 .nf
1902 Environment="ONE=one" \*(AqTWO=two two\*(Aq
1903 ExecStart=echo $ONE $TWO ${TWO}
1904 .fi
1905 .if n \{\
1906 .RE
1907 .\}
1908 .PP
1909 This will execute
1910 \fB/bin/echo\fR
1911 with four arguments:
1912 "one",
1913 "two",
1914 "two", and
1915 "two two"\&.
1916 .PP
1917 Example:
1918 .sp
1919 .if n \{\
1920 .RS 4
1921 .\}
1922 .nf
1923 Environment=ONE=\*(Aqone\*(Aq "TWO=\*(Aqtwo\ \&two\*(Aq\ \&too" THREE=
1924 ExecStart=/bin/echo ${ONE} ${TWO} ${THREE}
1925 ExecStart=/bin/echo $ONE $TWO $THREE
1926 .fi
1927 .if n \{\
1928 .RE
1929 .\}
1930 .PP
1931 This results in
1932 /bin/echo
1933 being called twice, the first time with arguments
1934 "\*(Aqone\*(Aq",
1935 "\*(Aqtwo\ \&two\*(Aq\ \&too",
1936 "", and the second time with arguments
1937 "one",
1938 "two\ \&two",
1939 "too"\&.
1940 .PP
1941 Unless for commands with the special executable prefix
1942 ":", to pass a literal dollar sign, use
1943 "$$"\&. Variables whose value is not known at expansion time are treated as empty strings\&. Note that the first argument (i\&.e\&. the program to execute) may not be a variable\&.
1944 .PP
1945 Variables to be used in this fashion may be defined through
1946 \fIEnvironment=\fR
1947 and
1948 \fIEnvironmentFile=\fR\&. In addition, variables listed in the section "Environment variables in spawned processes" in
1949 \fBsystemd.exec\fR(5), which are considered "static configuration", may be used (this includes e\&.g\&.
1950 \fI$USER\fR, but not
1951 \fI$TERM\fR)\&.
1952 .PP
1953 Note that shell command lines are not directly supported, and
1954 "|"
1955 invokes the user\*(Aqs default shell which isn\*(Aqt deterministic\&. It\*(Aqs recommended to specify a shell implementation explicitly if portability is desired\&. Example:
1956 .sp
1957 .if n \{\
1958 .RS 4
1959 .\}
1960 .nf
1961 ExecStart=sh \-c \*(Aqdmesg | tac\*(Aq
1962 .fi
1963 .if n \{\
1964 .RE
1965 .\}
1966 .PP
1967 Example:
1968 .sp
1969 .if n \{\
1970 .RS 4
1971 .\}
1972 .nf
1973 ExecStart=echo one
1974 ExecStart=echo "two two"
1975 .fi
1976 .if n \{\
1977 .RE
1978 .\}
1979 .PP
1980 This will execute
1981 \fBecho\fR
1982 two times, each time with one argument:
1983 "one"
1984 and
1985 "two two", respectively\&. Because two commands are specified,
1986 \fIType=oneshot\fR
1987 must be used\&.
1988 .PP
1989 Example:
1990 .sp
1991 .if n \{\
1992 .RS 4
1993 .\}
1994 .nf
1995 Type=oneshot
1996 ExecStart=:echo $USER
1997 ExecStart=\-false
1998 ExecStart=+:@true $TEST
1999 .fi
2000 .if n \{\
2001 .RE
2002 .\}
2003 .PP
2004 This will execute
2005 \fB/usr/bin/echo\fR
2006 with the literal argument
2007 "$USER"
2008 (":"
2009 suppresses variable expansion), and then
2010 \fB/usr/bin/false\fR
2011 (the return value will be ignored because
2012 "\-"
2013 suppresses checking of the return value), and
2014 \fB/usr/bin/true\fR
2015 (with elevated privileges, with
2016 "$TEST"
2017 as
2018 \fBargv[0]\fR)\&.
2019 .PP
2020 Example:
2021 .sp
2022 .if n \{\
2023 .RS 4
2024 .\}
2025 .nf
2026 ExecStart=echo / >/dev/null & \e; \e
2027 ls
2028 .fi
2029 .if n \{\
2030 .RE
2031 .\}
2032 .PP
2033 This will execute
2034 \fBecho\fR
2035 with five arguments:
2036 "/",
2037 ">/dev/null",
2038 "&",
2039 ";", and
2040 "ls"\&.
2041 .SH "EXAMPLES"
2042 .PP
2043 \fBExample\ \&3.\ \&Simple service\fR
2044 .PP
2045 The following unit file creates a service that will execute
2046 /usr/sbin/foo\-daemon\&. Since no
2047 \fIType=\fR
2048 is specified, the default
2049 \fIType=\fR\fBsimple\fR
2050 will be assumed\&. systemd will assume the unit to be started immediately after the program has begun executing\&.
2051 .sp
2052 .if n \{\
2053 .RS 4
2054 .\}
2055 .nf
2056 [Unit]
2057 Description=Foo
2058
2059 [Service]
2060 ExecStart=/usr/sbin/foo\-daemon
2061
2062 [Install]
2063 WantedBy=multi\-user\&.target
2064 .fi
2065 .if n \{\
2066 .RE
2067 .\}
2068 .PP
2069 Note that systemd assumes here that the process started by systemd will continue running until the service terminates\&. If the program daemonizes itself (i\&.e\&. forks), please use
2070 \fIType=\fR\fBforking\fR
2071 instead\&.
2072 .PP
2073 Since no
2074 \fIExecStop=\fR
2075 was specified, systemd will send SIGTERM to all processes started from this service, and after a timeout also SIGKILL\&. This behavior can be modified, see
2076 \fBsystemd.kill\fR(5)
2077 for details\&.
2078 .PP
2079 Note that this unit type does not include any type of notification when a service has completed initialization\&. For this, you should use other unit types, such as
2080 \fIType=\fR\fBnotify\fR/\fIType=\fR\fBnotify\-reload\fR
2081 if the service understands systemd\*(Aqs notification protocol,
2082 \fIType=\fR\fBforking\fR
2083 if the service can background itself or
2084 \fIType=\fR\fBdbus\fR
2085 if the unit acquires a DBus name once initialization is complete\&. See below\&.
2086 .PP
2087 \fBExample\ \&4.\ \&Oneshot service\fR
2088 .PP
2089 Sometimes, units should just execute an action without keeping active processes, such as a filesystem check or a cleanup action on boot\&. For this,
2090 \fIType=\fR\fBoneshot\fR
2091 exists\&. Units of this type will wait until the process specified terminates and then fall back to being inactive\&. The following unit will perform a cleanup action:
2092 .sp
2093 .if n \{\
2094 .RS 4
2095 .\}
2096 .nf
2097 [Unit]
2098 Description=Cleanup old Foo data
2099
2100 [Service]
2101 Type=oneshot
2102 ExecStart=/usr/sbin/foo\-cleanup
2103
2104 [Install]
2105 WantedBy=multi\-user\&.target
2106 .fi
2107 .if n \{\
2108 .RE
2109 .\}
2110 .PP
2111 Note that systemd will consider the unit to be in the state "starting" until the program has terminated, so ordered dependencies will wait for the program to finish before starting themselves\&. The unit will revert to the "inactive" state after the execution is done, never reaching the "active" state\&. That means another request to start the unit will perform the action again\&.
2112 .PP
2113 \fIType=\fR\fBoneshot\fR
2114 are the only service units that may have more than one
2115 \fIExecStart=\fR
2116 specified\&. For units with multiple commands (\fIType=oneshot\fR), all commands will be run again\&.
2117 .PP
2118 For
2119 \fIType=oneshot\fR,
2120 \fIRestart=\fR\fBalways\fR
2121 and
2122 \fIRestart=\fR\fBon\-success\fR
2123 are
2124 \fInot\fR
2125 allowed\&.
2126 .PP
2127 \fBExample\ \&5.\ \&Stoppable oneshot service\fR
2128 .PP
2129 Similarly to the oneshot services, there are sometimes units that need to execute a program to set up something and then execute another to shut it down, but no process remains active while they are considered "started"\&. Network configuration can sometimes fall into this category\&. Another use case is if a oneshot service shall not be executed each time when they are pulled in as a dependency, but only the first time\&.
2130 .PP
2131 For this, systemd knows the setting
2132 \fIRemainAfterExit=\fR\fByes\fR, which causes systemd to consider the unit to be active if the start action exited successfully\&. This directive can be used with all types, but is most useful with
2133 \fIType=\fR\fBoneshot\fR
2134 and
2135 \fIType=\fR\fBsimple\fR\&. With
2136 \fIType=\fR\fBoneshot\fR, systemd waits until the start action has completed before it considers the unit to be active, so dependencies start only after the start action has succeeded\&. With
2137 \fIType=\fR\fBsimple\fR, dependencies will start immediately after the start action has been dispatched\&. The following unit provides an example for a simple static firewall\&.
2138 .sp
2139 .if n \{\
2140 .RS 4
2141 .\}
2142 .nf
2143 [Unit]
2144 Description=Simple firewall
2145
2146 [Service]
2147 Type=oneshot
2148 RemainAfterExit=yes
2149 ExecStart=/usr/local/sbin/simple\-firewall\-start
2150 ExecStop=/usr/local/sbin/simple\-firewall\-stop
2151
2152 [Install]
2153 WantedBy=multi\-user\&.target
2154 .fi
2155 .if n \{\
2156 .RE
2157 .\}
2158 .PP
2159 Since the unit is considered to be running after the start action has exited, invoking
2160 \fBsystemctl start\fR
2161 on that unit again will cause no action to be taken\&.
2162 .PP
2163 \fBExample\ \&6.\ \&Traditional forking services\fR
2164 .PP
2165 Many traditional daemons/services background (i\&.e\&. fork, daemonize) themselves when starting\&. Set
2166 \fIType=\fR\fBforking\fR
2167 in the service\*(Aqs unit file to support this mode of operation\&. systemd will consider the service to be in the process of initialization while the original program is still running\&. Once it exits successfully and at least a process remains (and
2168 \fIRemainAfterExit=\fR\fBno\fR), the service is considered started\&.
2169 .PP
2170 Often, a traditional daemon only consists of one process\&. Therefore, if only one process is left after the original process terminates, systemd will consider that process the main process of the service\&. In that case, the
2171 \fI$MAINPID\fR
2172 variable will be available in
2173 \fIExecReload=\fR,
2174 \fIExecStop=\fR, etc\&.
2175 .PP
2176 In case more than one process remains, systemd will be unable to determine the main process, so it will not assume there is one\&. In that case,
2177 \fI$MAINPID\fR
2178 will not expand to anything\&. However, if the process decides to write a traditional PID file, systemd will be able to read the main PID from there\&. Please set
2179 \fIPIDFile=\fR
2180 accordingly\&. Note that the daemon should write that file before finishing with its initialization\&. Otherwise, systemd might try to read the file before it exists\&.
2181 .PP
2182 The following example shows a simple daemon that forks and just starts one process in the background:
2183 .sp
2184 .if n \{\
2185 .RS 4
2186 .\}
2187 .nf
2188 [Unit]
2189 Description=My Simple Daemon
2190
2191 [Service]
2192 Type=forking
2193 ExecStart=/usr/sbin/my\-simple\-daemon \-d
2194
2195 [Install]
2196 WantedBy=multi\-user\&.target
2197 .fi
2198 .if n \{\
2199 .RE
2200 .\}
2201 .PP
2202 Please see
2203 \fBsystemd.kill\fR(5)
2204 for details on how you can influence the way systemd terminates the service\&.
2205 .PP
2206 \fBExample\ \&7.\ \&DBus services\fR
2207 .PP
2208 For services that acquire a name on the DBus system bus, use
2209 \fIType=\fR\fBdbus\fR
2210 and set
2211 \fIBusName=\fR
2212 accordingly\&. The service should not fork (daemonize)\&. systemd will consider the service to be initialized once the name has been acquired on the system bus\&. The following example shows a typical DBus service:
2213 .sp
2214 .if n \{\
2215 .RS 4
2216 .\}
2217 .nf
2218 [Unit]
2219 Description=Simple DBus Service
2220
2221 [Service]
2222 Type=dbus
2223 BusName=org\&.example\&.simple\-dbus\-service
2224 ExecStart=/usr/sbin/simple\-dbus\-service
2225
2226 [Install]
2227 WantedBy=multi\-user\&.target
2228 .fi
2229 .if n \{\
2230 .RE
2231 .\}
2232 .PP
2233 For
2234 \fIbus\-activatable\fR
2235 services, do not include a [Install] section in the systemd service file, but use the
2236 \fISystemdService=\fR
2237 option in the corresponding DBus service file, for example (/usr/share/dbus\-1/system\-services/org\&.example\&.simple\-dbus\-service\&.service):
2238 .sp
2239 .if n \{\
2240 .RS 4
2241 .\}
2242 .nf
2243 [D\-BUS Service]
2244 Name=org\&.example\&.simple\-dbus\-service
2245 Exec=/usr/sbin/simple\-dbus\-service
2246 User=root
2247 SystemdService=simple\-dbus\-service\&.service
2248 .fi
2249 .if n \{\
2250 .RE
2251 .\}
2252 .PP
2253 Please see
2254 \fBsystemd.kill\fR(5)
2255 for details on how you can influence the way systemd terminates the service\&.
2256 .PP
2257 \fBExample\ \&8.\ \&Services that notify systemd about their initialization\fR
2258 .PP
2259 \fIType=\fR\fBsimple\fR
2260 services are really easy to write, but have the major disadvantage of systemd not being able to tell when initialization of the given service is complete\&. For this reason, systemd supports a simple notification protocol that allows daemons to make systemd aware that they are done initializing\&. Use
2261 \fIType=\fR\fBnotify\fR
2262 or
2263 \fIType=\fR\fBnotify\-reload\fR
2264 for this\&. A typical service file for such a daemon would look like this:
2265 .sp
2266 .if n \{\
2267 .RS 4
2268 .\}
2269 .nf
2270 [Unit]
2271 Description=Simple Notifying Service
2272
2273 [Service]
2274 Type=notify\-reload
2275 ExecStart=/usr/sbin/simple\-notifying\-service
2276
2277 [Install]
2278 WantedBy=multi\-user\&.target
2279 .fi
2280 .if n \{\
2281 .RE
2282 .\}
2283 .PP
2284 Note that the daemon has to support systemd\*(Aqs notification protocol, else systemd will think the service has not started yet and kill it after a timeout\&. For an example of how to update daemons to support this protocol transparently, take a look at
2285 \fBsd_notify\fR(3)\&. systemd will consider the unit to be in the \*(Aqstarting\*(Aq state until a readiness notification has arrived\&.
2286 .PP
2287 Please see
2288 \fBsystemd.kill\fR(5)
2289 for details on how you can influence the way systemd terminates the service\&.
2290 .PP
2291 To avoid code duplication, it is preferable to use
2292 \fBsd_notify\fR(3)
2293 when possible, especially when other APIs provided by
2294 \fBlibsystemd\fR(3)
2295 are also used, but note that the notification protocol is very simple and guaranteed to be stable as per the
2296 \m[blue]\fBInterface Portability and Stability Promise\fR\m[]\&\s-2\u[4]\d\s+2, so it can be reimplemented by services with no external dependencies\&. For a self\-contained example, see
2297 \fBsd_notify\fR(3)\&.
2298 .SH "SEE ALSO"
2299 .PP
2300 \fBsystemd\fR(1), \fBsystemctl\fR(1), \fBsystemd-system.conf\fR(5), \fBsystemd.unit\fR(5), \fBsystemd.exec\fR(5), \fBsystemd.resource-control\fR(5), \fBsystemd.kill\fR(5), \fBsystemd.directives\fR(7), \fBsystemd-run\fR(1)
2301 .SH "NOTES"
2302 .IP " 1." 4
2303 File Descriptor Store
2304 .RS 4
2305 \%https://systemd.io/FILE_DESCRIPTOR_STORE
2306 .RE
2307 .IP " 2." 4
2308 USB FunctionFS
2309 .RS 4
2310 \%https://docs.kernel.org/usb/functionfs.html
2311 .RE
2312 .IP " 3." 4
2313 Control Group v2
2314 .RS 4
2315 \%https://docs.kernel.org/admin-guide/cgroup-v2.html
2316 .RE
2317 .IP " 4." 4
2318 Interface Portability and Stability Promise
2319 .RS 4
2320 \%https://systemd.io/PORTABILITY_AND_STABILITY/
2321 .RE