Debian Codegraph @

upstream/debian-unstable/man5/systemd.service.5

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