1SYSTEMD.SERVICE(5)              systemd.service             SYSTEMD.SERVICE(5)
2
3
4

NAME

6       systemd.service - Service unit configuration
7

SYNOPSIS

9       service.service
10

DESCRIPTION

12       A unit configuration file whose name ends in ".service" encodes
13       information about a process controlled and supervised by systemd.
14
15       This man page lists the configuration options specific to this unit
16       type. See systemd.unit(5) for the common options of all unit
17       configuration files. The common configuration items are configured in
18       the generic "[Unit]" and "[Install]" sections. The service specific
19       configuration options are configured in the "[Service]" section.
20
21       Additional options are listed in systemd.exec(5), which define the
22       execution environment the commands are executed in, and in
23       systemd.kill(5), which define the way the processes of the service are
24       terminated, and in systemd.resource-control(5), which configure
25       resource control settings for the processes of the service.
26
27       If a service is requested under a certain name but no unit
28       configuration file is found, systemd looks for a SysV init script by
29       the same name (with the .service suffix removed) and dynamically
30       creates a service unit from that script. This is useful for
31       compatibility with SysV. Note that this compatibility is quite
32       comprehensive but not 100%. For details about the incompatibilities,
33       see the Incompatibilities with SysV[1] document.
34
35       The systemd-run(1) command allows creating .service and .scope units
36       dynamically and transiently from the command line.
37

SERVICE TEMPLATES

39       It is possible for systemd services to take a single argument via the
40       "service@argument.service" syntax. Such services are called
41       "instantiated" services, while the unit definition without the argument
42       parameter is called a "template". An example could be a dhcpcd@.service
43       service template which takes a network interface as a parameter to form
44       an instantiated service. Within the service file, this parameter or
45       "instance name" can be accessed with %-specifiers. See systemd.unit(5)
46       for details.
47

AUTOMATIC DEPENDENCIES

49   Implicit Dependencies
50       The following dependencies are implicitly added:
51
52       ·   Services with Type=dbus set automatically acquire dependencies of
53           type Requires= and After= on dbus.socket.
54
55       ·   Socket activated services are automatically ordered after their
56           activating .socket units via an automatic After= dependency.
57           Services also pull in all .socket units listed in Sockets= via
58           automatic Wants= and After= dependencies.
59
60       Additional implicit dependencies may be added as result of execution
61       and resource control parameters as documented in systemd.exec(5) and
62       systemd.resource-control(5).
63
64   Default Dependencies
65       The following dependencies are added unless DefaultDependencies=no is
66       set:
67
68       ·   Service units will have dependencies of type Requires= and After=
69           on sysinit.target, a dependency of type After= on basic.target as
70           well as dependencies of type Conflicts= and Before= on
71           shutdown.target. These ensure that normal service units pull in
72           basic system initialization, and are terminated cleanly prior to
73           system shutdown. Only services involved with early boot or late
74           system shutdown should disable this option.
75
76       ·   Instanced service units (i.e. service units with an "@" in their
77           name) are assigned by default a per-template slice unit (see
78           systemd.slice(5)), named after the template unit, containing all
79           instances of the specific template. This slice is normally stopped
80           at shutdown, together with all template instances. If that is not
81           desired, set DefaultDependencies=no in the template unit, and
82           either define your own per-template slice unit file that also sets
83           DefaultDependencies=no, or set Slice=system.slice (or another
84           suitable slice) in the template unit. Also see systemd.resource-
85           control(5).
86

OPTIONS

88       Service files must include a "[Service]" section, which carries
89       information about the service and the process it supervises. A number
90       of options that may be used in this section are shared with other unit
91       types. These options are documented in systemd.exec(5), systemd.kill(5)
92       and systemd.resource-control(5). The options specific to the
93       "[Service]" section of service units are the following:
94
95       Type=
96           Configures the process start-up type for this service unit. One of
97           simple, exec, forking, oneshot, dbus, notify or idle:
98
99           ·   If set to simple (the default if ExecStart= is specified but
100               neither Type= nor BusName= are), the service manager will
101               consider the unit started immediately after the main service
102               process has been forked off. It is expected that the process
103               configured with ExecStart= is the main process of the service.
104               In this mode, if the process offers functionality to other
105               processes on the system, its communication channels should be
106               installed before the service is started up (e.g. sockets set up
107               by systemd, via socket activation), as the service manager will
108               immediately proceed starting follow-up units, right after
109               creating the main service process, and before executing the
110               service's binary. Note that this means systemctl start command
111               lines for simple services will report success even if the
112               service's binary cannot be invoked successfully (for example
113               because the selected User= doesn't exist, or the service binary
114               is missing).
115
116           ·   The exec type is similar to simple, but the service manager
117               will consider the unit started immediately after the main
118               service binary has been executed. The service manager will
119               delay starting of follow-up units until that point. (Or in
120               other words: simple proceeds with further jobs right after
121               fork() returns, while exec will not proceed before both fork()
122               and execve() in the service process succeeded.) Note that this
123               means systemctl start command lines for exec services will
124               report failure when the service's binary cannot be invoked
125               successfully (for example because the selected User= doesn't
126               exist, or the service binary is missing).
127
128           ·   If set to forking, it is expected that the process configured
129               with ExecStart= will call fork() as part of its start-up. The
130               parent process is expected to exit when start-up is complete
131               and all communication channels are set up. The child continues
132               to run as the main service process, and the service manager
133               will consider the unit started when the parent process exits.
134               This is the behavior of traditional UNIX services. If this
135               setting is used, it is recommended to also use the PIDFile=
136               option, so that systemd can reliably identify the main process
137               of the service. systemd will proceed with starting follow-up
138               units as soon as the parent process exits.
139
140           ·   Behavior of oneshot is similar to simple; however, the service
141               manager will consider the unit up after the main process exits.
142               It will then start follow-up units.  RemainAfterExit= is
143               particularly useful for this type of service.  Type=oneshot is
144               the implied default if neither Type= nor ExecStart= are
145               specified. Note that if this option is used without
146               RemainAfterExit= the service will never enter "active" unit
147               state, but directly transition from "activating" to
148               "deactivating" or "dead" since no process is configured that
149               shall run continously. In particular this means that after a
150               service of this type ran (and which has RemainAfterExit= not
151               set) it will not show up as started afterwards, but as dead.
152
153           ·   Behavior of dbus is similar to simple; however, it is expected
154               that the service acquires a name on the D-Bus bus, as
155               configured by BusName=. systemd will proceed with starting
156               follow-up units after the D-Bus bus name has been acquired.
157               Service units with this option configured implicitly gain
158               dependencies on the dbus.socket unit. This type is the default
159               if BusName= is specified.
160
161           ·   Behavior of notify is similar to exec; however, it is expected
162               that the service sends a notification message via sd_notify(3)
163               or an equivalent call when it has finished starting up. systemd
164               will proceed with starting follow-up units after this
165               notification message has been sent. If this option is used,
166               NotifyAccess= (see below) should be set to open access to the
167               notification socket provided by systemd. If NotifyAccess= is
168               missing or set to none, it will be forcibly set to main
169           .
170
171
172
173           ·   Behavior of idle is very similar to simple; however, actual
174               execution of the service program is delayed until all active
175               jobs are dispatched. This may be used to avoid interleaving of
176               output of shell services with the status output on the console.
177               Note that this type is useful only to improve console output,
178               it is not useful as a general unit ordering tool, and the
179               effect of this service type is subject to a 5s timeout, after
180               which the service program is invoked anyway.
181
182           It is generally recommended to use Type=simple for long-running
183           services whenever possible, as it is the simplest and fastest
184           option. However, as this service type won't propagate service
185           start-up failures and doesn't allow ordering of other units against
186           completion of initialization of the service (which for example is
187           useful if clients need to connect to the service through some form
188           of IPC, and the IPC channel is only established by the service
189           itself — in contrast to doing this ahead of time through socket or
190           bus activation or similar), it might not be sufficient for many
191           cases. If so, notify or dbus (the latter only in case the service
192           provides a D-Bus interface) are the preferred options as they allow
193           service program code to precisely schedule when to consider the
194           service started up successfully and when to proceed with follow-up
195           units. The notify service type requires explicit support in the
196           service codebase (as sd_notify() or an equivalent API needs to be
197           invoked by the service at the appropriate time) — if it's not
198           supported, then forking is an alternative: it supports the
199           traditional UNIX service start-up protocol. Finally, exec might be
200           an option for cases where it is enough to ensure the service binary
201           is invoked, and where the service binary itself executes no or
202           little initialization on its own (and its initialization is
203           unlikely to fail). Note that using any type other than simple
204           possibly delays the boot process, as the service manager needs to
205           wait for service initialization to complete. It is hence
206           recommended not to needlessly use any types other than simple.
207           (Also note it is generally not recommended to use idle or oneshot
208           for long-running services.)
209
210       RemainAfterExit=
211           Takes a boolean value that specifies whether the service shall be
212           considered active even when all its processes exited. Defaults to
213           no.
214
215       GuessMainPID=
216           Takes a boolean value that specifies whether systemd should try to
217           guess the main PID of a service if it cannot be determined
218           reliably. This option is ignored unless Type=forking is set and
219           PIDFile= is unset because for the other types or with an explicitly
220           configured PID file, the main PID is always known. The guessing
221           algorithm might come to incorrect conclusions if a daemon consists
222           of more than one process. If the main PID cannot be determined,
223           failure detection and automatic restarting of a service will not
224           work reliably. Defaults to yes.
225
226       PIDFile=
227           Takes a path referring to the PID file of the service. Usage of
228           this option is recommended for services where Type= is set to
229           forking. The path specified typically points to a file below /run/.
230           If a relative path is specified it is hence prefixed with /run/.
231           The service manager will read the PID of the main process of the
232           service from this file after start-up of the service. The service
233           manager will not write to the file configured here, although it
234           will remove the file after the service has shut down if it still
235           exists. The PID file does not need to be owned by a privileged
236           user, but if it is owned by an unprivileged user additional safety
237           restrictions are enforced: the file may not be a symlink to a file
238           owned by a different user (neither directly nor indirectly), and
239           the PID file must refer to a process already belonging to the
240           service.
241
242       BusName=
243           Takes a D-Bus bus name that this service is reachable as. This
244           option is mandatory for services where Type= is set to dbus.
245
246       ExecStart=
247           Commands with their arguments that are executed when this service
248           is started. The value is split into zero or more command lines
249           according to the rules described below (see section "Command Lines"
250           below).
251
252           Unless Type= is oneshot, exactly one command must be given. When
253           Type=oneshot is used, zero or more commands may be specified.
254           Commands may be specified by providing multiple command lines in
255           the same directive, or alternatively, this directive may be
256           specified more than once with the same effect. If the empty string
257           is assigned to this option, the list of commands to start is reset,
258           prior assignments of this option will have no effect. If no
259           ExecStart= is specified, then the service must have
260           RemainAfterExit=yes and at least one ExecStop= line set. (Services
261           lacking both ExecStart= and ExecStop= are not valid.)
262
263           For each of the specified commands, the first argument must be
264           either an absolute path to an executable or a simple file name
265           without any slashes. Optionally, this filename may be prefixed with
266           a number of special characters:
267
268           Table 1. Special executable prefixes
269           ┌───────┬────────────────────────────┐
270Prefix Effect                     
271           ├───────┼────────────────────────────┤
272           │"@"    │ If the executable path is  │
273           │       │ prefixed with "@", the     │
274           │       │ second specified token     │
275           │       │ will be passed as          │
276           │       │ "argv[0]" to the executed  │
277           │       │ process (instead of the    │
278           │       │ actual filename), followed │
279           │       │ by the further arguments   │
280           │       │ specified.                 │
281           ├───────┼────────────────────────────┤
282           │"-"    │ If the executable path is  │
283           │       │ prefixed with "-", an exit │
284           │       │ code of the command        │
285           │       │ normally considered a      │
286           │       │ failure (i.e. non-zero     │
287           │       │ exit status or abnormal    │
288           │       │ exit due to signal) is     │
289           │       │ recorded, but has no       │
290           │       │ further effect and is      │
291           │       │ considered equivalent to   │
292           │       │ success.                   │
293           ├───────┼────────────────────────────┤
294           │":"    │ If the executable path is  │
295           │       │ prefixed with ":",         │
296           │       │ environment variable       │
297           │       │ substitution (as described │
298           │       │ by the "Command Lines"     │
299           │       │ section below) is not      │
300           │       │ applied.                   │
301           ├───────┼────────────────────────────┤
302           │"+"    │ If the executable path is  │
303           │       │ prefixed with "+" then the │
304           │       │ process is executed with   │
305           │       │ full privileges. In this   │
306           │       │ mode privilege             │
307           │       │ restrictions configured    │
308           │       │ with User=, Group=,        │
309           │       │ CapabilityBoundingSet= or  │
310           │       │ the various file system    │
311           │       │ namespacing options (such  │
312           │       │ as PrivateDevices=,        │
313           │       │ PrivateTmp=) are not       │
314           │       │ applied to the invoked     │
315           │       │ command line (but still    │
316           │       │ affect any other           │
317           │       │ ExecStart=, ExecStop=, ... │
318           │       │ lines).                    │
319           ├───────┼────────────────────────────┤
320           │"!"    │ Similar to the "+"         │
321           │       │ character discussed above  │
322           │       │ this permits invoking      │
323           │       │ command lines with         │
324           │       │ elevated privileges.       │
325           │       │ However, unlike "+" the    │
326           │       │ "!" character exclusively  │
327           │       │ alters the effect of       │
328           │       │ User=, Group= and          │
329           │       │ SupplementaryGroups=, i.e. │
330           │       │ only the stanzas that      │
331           │       │ affect user and group      │
332           │       │ credentials. Note that     │
333           │       │ this setting may be        │
334           │       │ combined with              │
335           │       │ DynamicUser=, in which     │
336           │       │ case a dynamic user/group  │
337           │       │ pair is allocated before   │
338           │       │ the command is invoked,    │
339           │       │ but credential changing is │
340           │       │ left to the executed       │
341           │       │ process itself.            │
342           ├───────┼────────────────────────────┤
343           │"!!"   │ This prefix is very        │
344           │       │ similar to "!", however it │
345           │       │ only has an effect on      │
346           │       │ systems lacking support    │
347           │       │ for ambient process        │
348           │       │ capabilities, i.e. without │
349           │       │ support for                │
350           │       │ AmbientCapabilities=. It's │
351           │       │ intended to be used for    │
352           │       │ unit files that take       │
353           │       │ benefit of ambient         │
354           │       │ capabilities to run        │
355           │       │ processes with minimal     │
356           │       │ privileges wherever        │
357           │       │ possible while remaining   │
358           │       │ compatible with systems    │
359           │       │ that lack ambient          │
360           │       │ capabilities support. Note │
361           │       │ that when "!!" is used,    │
362           │       │ and a system lacking       │
363           │       │ ambient capability support │
364           │       │ is detected any configured │
365           │       │ SystemCallFilter= and      │
366           │       │ CapabilityBoundingSet=
367           │       │ stanzas are implicitly     │
368           │       │ modified, in order to      │
369           │       │ permit spawned processes   │
370           │       │ to drop credentials and    │
371           │       │ capabilities themselves,   │
372           │       │ even if this is configured │
373           │       │ to not be allowed.         │
374           │       │ Moreover, if this prefix   │
375           │       │ is used and a system       │
376           │       │ lacking ambient capability │
377           │       │ support is detected        │
378           │       │ AmbientCapabilities= will  │
379           │       │ be skipped and not be      │
380           │       │ applied. On systems        │
381           │       │ supporting ambient         │
382           │       │ capabilities, "!!" has no  │
383           │       │ effect and is redundant.   │
384           └───────┴────────────────────────────┘
385           "@", "-", ":", and one of "+"/"!"/"!!"  may be used together and
386           they can appear in any order. However, only one of "+", "!", "!!"
387           may be used at a time. Note that these prefixes are also supported
388           for the other command line settings, i.e.  ExecStartPre=,
389           ExecStartPost=, ExecReload=, ExecStop= and ExecStopPost=.
390
391           If more than one command is specified, the commands are invoked
392           sequentially in the order they appear in the unit file. If one of
393           the commands fails (and is not prefixed with "-"), other lines are
394           not executed, and the unit is considered failed.
395
396           Unless Type=forking is set, the process started via this command
397           line will be considered the main process of the daemon.
398
399       ExecStartPre=, ExecStartPost=
400           Additional commands that are executed before or after the command
401           in ExecStart=, respectively. Syntax is the same as for ExecStart=,
402           except that multiple command lines are allowed and the commands are
403           executed one after the other, serially.
404
405           If any of those commands (not prefixed with "-") fail, the rest are
406           not executed and the unit is considered failed.
407
408           ExecStart= commands are only run after all ExecStartPre= commands
409           that were not prefixed with a "-" exit successfully.
410
411           ExecStartPost= commands are only run after the commands specified
412           in ExecStart= have been invoked successfully, as determined by
413           Type= (i.e. the process has been started for Type=simple or
414           Type=idle, the last ExecStart= process exited successfully for
415           Type=oneshot, the initial process exited successfully for
416           Type=forking, "READY=1" is sent for Type=notify, or the BusName=
417           has been taken for Type=dbus).
418
419           Note that ExecStartPre= may not be used to start long-running
420           processes. All processes forked off by processes invoked via
421           ExecStartPre= will be killed before the next service process is
422           run.
423
424           Note that if any of the commands specified in ExecStartPre=,
425           ExecStart=, or ExecStartPost= fail (and are not prefixed with "-",
426           see above) or time out before the service is fully up, execution
427           continues with commands specified in ExecStopPost=, the commands in
428           ExecStop= are skipped.
429
430       ExecCondition=
431           Optional commands that are executed before the command(s) in
432           ExecStartPre=. Syntax is the same as for ExecStart=, except that
433           multiple command lines are allowed and the commands are executed
434           one after the other, serially.
435
436           The behavior is like an ExecStartPre= and condition check hybrid:
437           when an ExecCondition= command exits with exit code 1 through 254
438           (inclusive), the remaining commands are skipped and the unit is not
439           marked as failed. However, if an ExecCondition= command exits with
440           255 or abnormally (e.g. timeout, killed by a signal, etc.), the
441           unit will be considered failed (and remaining commands will be
442           skipped). Exit code of 0 or those matching SuccessExitStatus= will
443           continue execution to the next command(s).
444
445           The same recommendations about not running long-running processes
446           in ExecStartPre= also applies to ExecCondition=.  ExecCondition=
447           will also run the commands in ExecStopPost=, as part of stopping
448           the service, in the case of any non-zero or abnormal exits, like
449           the ones described above.
450
451       ExecReload=
452           Commands to execute to trigger a configuration reload in the
453           service. This argument takes multiple command lines, following the
454           same scheme as described for ExecStart= above. Use of this setting
455           is optional. Specifier and environment variable substitution is
456           supported here following the same scheme as for ExecStart=.
457
458           One additional, special environment variable is set: if known,
459           $MAINPID is set to the main process of the daemon, and may be used
460           for command lines like the following:
461
462               /bin/kill -HUP $MAINPID
463
464           Note however that reloading a daemon by sending a signal (as with
465           the example line above) is usually not a good choice, because this
466           is an asynchronous operation and hence not suitable to order
467           reloads of multiple services against each other. It is strongly
468           recommended to set ExecReload= to a command that not only triggers
469           a configuration reload of the daemon, but also synchronously waits
470           for it to complete.
471
472       ExecStop=
473           Commands to execute to stop the service started via ExecStart=.
474           This argument takes multiple command lines, following the same
475           scheme as described for ExecStart= above. Use of this setting is
476           optional. After the commands configured in this option are run, it
477           is implied that the service is stopped, and any processes remaining
478           for it are terminated according to the KillMode= setting (see
479           systemd.kill(5)). If this option is not specified, the process is
480           terminated by sending the signal specified in KillSignal= or
481           RestartKillSignal= when service stop is requested. Specifier and
482           environment variable substitution is supported (including $MAINPID,
483           see above).
484
485           Note that it is usually not sufficient to specify a command for
486           this setting that only asks the service to terminate (for example,
487           by sending some form of termination signal to it), but does not
488           wait for it to do so. Since the remaining processes of the services
489           are killed according to KillMode= and KillSignal= or
490           RestartKillSignal= as described above immediately after the command
491           exited, this may not result in a clean stop. The specified command
492           should hence be a synchronous operation, not an asynchronous one.
493
494           Note that the commands specified in ExecStop= are only executed
495           when the service started successfully first. They are not invoked
496           if the service was never started at all, or in case its start-up
497           failed, for example because any of the commands specified in
498           ExecStart=, ExecStartPre= or ExecStartPost= failed (and weren't
499           prefixed with "-", see above) or timed out. Use ExecStopPost= to
500           invoke commands when a service failed to start up correctly and is
501           shut down again. Also note that the stop operation is always
502           performed if the service started successfully, even if the
503           processes in the service terminated on their own or were killed.
504           The stop commands must be prepared to deal with that case.
505           $MAINPID will be unset if systemd knows that the main process
506           exited by the time the stop commands are called.
507
508           Service restart requests are implemented as stop operations
509           followed by start operations. This means that ExecStop= and
510           ExecStopPost= are executed during a service restart operation.
511
512           It is recommended to use this setting for commands that communicate
513           with the service requesting clean termination. For post-mortem
514           clean-up steps use ExecStopPost= instead.
515
516       ExecStopPost=
517           Additional commands that are executed after the service is stopped.
518           This includes cases where the commands configured in ExecStop= were
519           used, where the service does not have any ExecStop= defined, or
520           where the service exited unexpectedly. This argument takes multiple
521           command lines, following the same scheme as described for
522           ExecStart=. Use of these settings is optional. Specifier and
523           environment variable substitution is supported. Note that – unlike
524           ExecStop= – commands specified with this setting are invoked when a
525           service failed to start up correctly and is shut down again.
526
527           It is recommended to use this setting for clean-up operations that
528           shall be executed even when the service failed to start up
529           correctly. Commands configured with this setting need to be able to
530           operate even if the service failed starting up half-way and left
531           incompletely initialized data around. As the service's processes
532           have been terminated already when the commands specified with this
533           setting are executed they should not attempt to communicate with
534           them.
535
536           Note that all commands that are configured with this setting are
537           invoked with the result code of the service, as well as the main
538           process' exit code and status, set in the $SERVICE_RESULT,
539           $EXIT_CODE and $EXIT_STATUS environment variables, see
540           systemd.exec(5) for details.
541
542       RestartSec=
543           Configures the time to sleep before restarting a service (as
544           configured with Restart=). Takes a unit-less value in seconds, or a
545           time span value such as "5min 20s". Defaults to 100ms.
546
547       TimeoutStartSec=
548           Configures the time to wait for start-up. If a daemon service does
549           not signal start-up completion within the configured time, the
550           service will be considered failed and will be shut down again.
551           Takes a unit-less value in seconds, or a time span value such as
552           "5min 20s". Pass "infinity" to disable the timeout logic. Defaults
553           to DefaultTimeoutStartSec= from the manager configuration file,
554           except when Type=oneshot is used, in which case the timeout is
555           disabled by default (see systemd-system.conf(5)).
556
557           If a service of Type=notify sends "EXTEND_TIMEOUT_USEC=...", this
558           may cause the start time to be extended beyond TimeoutStartSec=.
559           The first receipt of this message must occur before
560           TimeoutStartSec= is exceeded, and once the start time has exended
561           beyond TimeoutStartSec=, the service manager will allow the service
562           to continue to start, provided the service repeats
563           "EXTEND_TIMEOUT_USEC=..."  within the interval specified until the
564           service startup status is finished by "READY=1". (see
565           sd_notify(3)).
566
567       TimeoutStopSec=
568           This option serves two purposes. First, it configures the time to
569           wait for each ExecStop= command. If any of them times out,
570           subsequent ExecStop= commands are skipped and the service will be
571           terminated by SIGTERM. If no ExecStop= commands are specified, the
572           service gets the SIGTERM immediately. Second, it configures the
573           time to wait for the service itself to stop. If it doesn't
574           terminate in the specified time, it will be forcibly terminated by
575           SIGKILL (see KillMode= in systemd.kill(5)). Takes a unit-less value
576           in seconds, or a time span value such as "5min 20s". Pass
577           "infinity" to disable the timeout logic. Defaults to
578           DefaultTimeoutStopSec= from the manager configuration file (see
579           systemd-system.conf(5)).
580
581           If a service of Type=notify sends "EXTEND_TIMEOUT_USEC=...", this
582           may cause the stop time to be extended beyond TimeoutStopSec=. The
583           first receipt of this message must occur before TimeoutStopSec= is
584           exceeded, and once the stop time has exended beyond
585           TimeoutStopSec=, the service manager will allow the service to
586           continue to stop, provided the service repeats
587           "EXTEND_TIMEOUT_USEC=..."  within the interval specified, or
588           terminates itself (see sd_notify(3)).
589
590       TimeoutAbortSec=
591           This option configures the time to wait for the service to
592           terminate when it was aborted due to a watchdog timeout (see
593           WatchdogSec=). If the service has a short TimeoutStopSec= this
594           option can be used to give the system more time to write a core
595           dump of the service. Upon expiration the service will be forcibly
596           terminated by SIGKILL (see KillMode= in systemd.kill(5)). The core
597           file will be truncated in this case. Use TimeoutAbortSec= to set a
598           sensible timeout for the core dumping per service that is large
599           enough to write all expected data while also being short enough to
600           handle the service failure in due time.
601
602           Takes a unit-less value in seconds, or a time span value such as
603           "5min 20s". Pass an empty value to skip the dedicated watchdog
604           abort timeout handling and fall back TimeoutStopSec=. Pass
605           "infinity" to disable the timeout logic. Defaults to
606           DefaultTimeoutAbortSec= from the manager configuration file (see
607           systemd-system.conf(5)).
608
609           If a service of Type=notify handles SIGABRT itself (instead of
610           relying on the kernel to write a core dump) it can send
611           "EXTEND_TIMEOUT_USEC=..."  to extended the abort time beyond
612           TimeoutAbortSec=. The first receipt of this message must occur
613           before TimeoutAbortSec= is exceeded, and once the abort time has
614           exended beyond TimeoutAbortSec=, the service manager will allow the
615           service to continue to abort, provided the service repeats
616           "EXTEND_TIMEOUT_USEC=..."  within the interval specified, or
617           terminates itself (see sd_notify(3)).
618
619       TimeoutSec=
620           A shorthand for configuring both TimeoutStartSec= and
621           TimeoutStopSec= to the specified value.
622
623       RuntimeMaxSec=
624           Configures a maximum time for the service to run. If this is used
625           and the service has been active for longer than the specified time
626           it is terminated and put into a failure state. Note that this
627           setting does not have any effect on Type=oneshot services, as they
628           terminate immediately after activation completed. Pass "infinity"
629           (the default) to configure no runtime limit.
630
631           If a service of Type=notify sends "EXTEND_TIMEOUT_USEC=...", this
632           may cause the runtime to be extended beyond RuntimeMaxSec=. The
633           first receipt of this message must occur before RuntimeMaxSec= is
634           exceeded, and once the runtime has exended beyond RuntimeMaxSec=,
635           the service manager will allow the service to continue to run,
636           provided the service repeats "EXTEND_TIMEOUT_USEC=..."  within the
637           interval specified until the service shutdown is achieved by
638           "STOPPING=1" (or termination). (see sd_notify(3)).
639
640       WatchdogSec=
641           Configures the watchdog timeout for a service. The watchdog is
642           activated when the start-up is completed. The service must call
643           sd_notify(3) regularly with "WATCHDOG=1" (i.e. the "keep-alive
644           ping"). If the time between two such calls is larger than the
645           configured time, then the service is placed in a failed state and
646           it will be terminated with SIGABRT (or the signal specified by
647           WatchdogSignal=). By setting Restart= to on-failure, on-watchdog,
648           on-abnormal or always, the service will be automatically restarted.
649           The time configured here will be passed to the executed service
650           process in the WATCHDOG_USEC= environment variable. This allows
651           daemons to automatically enable the keep-alive pinging logic if
652           watchdog support is enabled for the service. If this option is
653           used, NotifyAccess= (see below) should be set to open access to the
654           notification socket provided by systemd. If NotifyAccess= is not
655           set, it will be implicitly set to main. Defaults to 0, which
656           disables this feature. The service can check whether the service
657           manager expects watchdog keep-alive notifications. See
658           sd_watchdog_enabled(3) for details.  sd_event_set_watchdog(3) may
659           be used to enable automatic watchdog notification support.
660
661       Restart=
662           Configures whether the service shall be restarted when the service
663           process exits, is killed, or a timeout is reached. The service
664           process may be the main service process, but it may also be one of
665           the processes specified with ExecStartPre=, ExecStartPost=,
666           ExecStop=, ExecStopPost=, or ExecReload=. When the death of the
667           process is a result of systemd operation (e.g. service stop or
668           restart), the service will not be restarted. Timeouts include
669           missing the watchdog "keep-alive ping" deadline and a service
670           start, reload, and stop operation timeouts.
671
672           Takes one of no, on-success, on-failure, on-abnormal, on-watchdog,
673           on-abort, or always. If set to no (the default), the service will
674           not be restarted. If set to on-success, it will be restarted only
675           when the service process exits cleanly. In this context, a clean
676           exit means an exit code of 0, or one of the signals SIGHUP, SIGINT,
677           SIGTERM or SIGPIPE, and additionally, exit statuses and signals
678           specified in SuccessExitStatus=. If set to on-failure, the service
679           will be restarted when the process exits with a non-zero exit code,
680           is terminated by a signal (including on core dump, but excluding
681           the aforementioned four signals), when an operation (such as
682           service reload) times out, and when the configured watchdog timeout
683           is triggered. If set to on-abnormal, the service will be restarted
684           when the process is terminated by a signal (including on core dump,
685           excluding the aforementioned four signals), when an operation times
686           out, or when the watchdog timeout is triggered. If set to on-abort,
687           the service will be restarted only if the service process exits due
688           to an uncaught signal not specified as a clean exit status. If set
689           to on-watchdog, the service will be restarted only if the watchdog
690           timeout for the service expires. If set to always, the service will
691           be restarted regardless of whether it exited cleanly or not, got
692           terminated abnormally by a signal, or hit a timeout.
693
694           Table 2. Exit causes and the effect of the Restart= settings on
695           them
696           ┌──────────────┬────┬────────┬────────────┬────────────┬─────────────┬──────────┬─────────────┐
697Restart       no always on-success on-failure on-abnormal on-abort on-watchdog 
698settings/Exit │    │        │            │            │             │          │             │
699causes        │    │        │            │            │             │          │             │
700           ├──────────────┼────┼────────┼────────────┼────────────┼─────────────┼──────────┼─────────────┤
701           │Clean exit    │    │ X      │ X          │            │             │          │             │
702           │code or       │    │        │            │            │             │          │             │
703           │signal        │    │        │            │            │             │          │             │
704           ├──────────────┼────┼────────┼────────────┼────────────┼─────────────┼──────────┼─────────────┤
705           │Unclean exit  │    │ X      │            │ X          │             │          │             │
706           │code          │    │        │            │            │             │          │             │
707           ├──────────────┼────┼────────┼────────────┼────────────┼─────────────┼──────────┼─────────────┤
708           │Unclean       │    │ X      │            │ X          │ X           │ X        │             │
709           │signal        │    │        │            │            │             │          │             │
710           ├──────────────┼────┼────────┼────────────┼────────────┼─────────────┼──────────┼─────────────┤
711           │Timeout       │    │ X      │            │ X          │ X           │          │             │
712           ├──────────────┼────┼────────┼────────────┼────────────┼─────────────┼──────────┼─────────────┤
713           │Watchdog      │    │ X      │            │ X          │ X           │          │ X           │
714           └──────────────┴────┴────────┴────────────┴────────────┴─────────────┴──────────┴─────────────┘
715           As exceptions to the setting above, the service will not be
716           restarted if the exit code or signal is specified in
717           RestartPreventExitStatus= (see below) or the service is stopped
718           with systemctl stop or an equivalent operation. Also, the services
719           will always be restarted if the exit code or signal is specified in
720           RestartForceExitStatus= (see below).
721
722           Note that service restart is subject to unit start rate limiting
723           configured with StartLimitIntervalSec= and StartLimitBurst=, see
724           systemd.unit(5) for details. A restarted service enters the failed
725           state only after the start limits are reached.
726
727           Setting this to on-failure is the recommended choice for
728           long-running services, in order to increase reliability by
729           attempting automatic recovery from errors. For services that shall
730           be able to terminate on their own choice (and avoid immediate
731           restarting), on-abnormal is an alternative choice.
732
733       SuccessExitStatus=
734           Takes a list of exit status definitions that, when returned by the
735           main service process, will be considered successful termination, in
736           addition to the normal successful exit code 0 and the signals
737           SIGHUP, SIGINT, SIGTERM, and SIGPIPE. Exit status definitions can
738           be numeric exit codes, termination code names, or termination
739           signal names, separated by spaces. See the Process Exit Codes
740           section in systemd.exec(5) for a list of termination codes names
741           (for this setting only the part without the "EXIT_" or "EX_" prefix
742           should be used). See signal(7) for a list of signal names.
743
744           This option may appear more than once, in which case the list of
745           successful exit statuses is merged. If the empty string is assigned
746           to this option, the list is reset, all prior assignments of this
747           option will have no effect.
748
749           Example 1. A service with with the SuccessExitStatus= setting
750
751               SuccessExitStatus=TEMPFAIL 250 SIGUSR1
752
753           Exit codes 75 (TEMPFAIL), 250, and the termination signal SIGKILL
754           are considered clean service terminations.
755
756           Note: systemd-analyze exit-codes may be used to list exit codes and
757           translate between numerical code values and names.
758
759       RestartPreventExitStatus=
760           Takes a list of exit status definitions that, when returned by the
761           main service process, will prevent automatic service restarts,
762           regardless of the restart setting configured with Restart=. Exit
763           status definitions can either be numeric exit codes or termination
764           signal names, and are separated by spaces. Defaults to the empty
765           list, so that, by default, no exit status is excluded from the
766           configured restart logic. For example:
767
768               RestartPreventExitStatus=1 6 SIGABRT
769
770           ensures that exit codes 1 and 6 and the termination signal SIGABRT
771           will not result in automatic service restarting. This option may
772           appear more than once, in which case the list of restart-preventing
773           statuses is merged. If the empty string is assigned to this option,
774           the list is reset and all prior assignments of this option will
775           have no effect.
776
777           Note that this setting has no effect on processes configured via
778           ExecStartPre=, ExecStartPost=, ExecStop=, ExecStopPost= or
779           ExecReload=, but only on the main service process, i.e. either the
780           one invoked by ExecStart= or (depending on Type=, PIDFile=, ...)
781           the otherwise configured main process.
782
783       RestartForceExitStatus=
784           Takes a list of exit status definitions that, when returned by the
785           main service process, will force automatic service restarts,
786           regardless of the restart setting configured with Restart=. The
787           argument format is similar to RestartPreventExitStatus=.
788
789       RootDirectoryStartOnly=
790           Takes a boolean argument. If true, the root directory, as
791           configured with the RootDirectory= option (see systemd.exec(5) for
792           more information), is only applied to the process started with
793           ExecStart=, and not to the various other ExecStartPre=,
794           ExecStartPost=, ExecReload=, ExecStop=, and ExecStopPost= commands.
795           If false, the setting is applied to all configured commands the
796           same way. Defaults to false.
797
798       NonBlocking=
799           Set the O_NONBLOCK flag for all file descriptors passed via
800           socket-based activation. If true, all file descriptors >= 3 (i.e.
801           all except stdin, stdout, stderr), excluding those passed in via
802           the file descriptor storage logic (see FileDescriptorStoreMax= for
803           details), will have the O_NONBLOCK flag set and hence are in
804           non-blocking mode. This option is only useful in conjunction with a
805           socket unit, as described in systemd.socket(5) and has no effect on
806           file descriptors which were previously saved in the file-descriptor
807           store for example. Defaults to false.
808
809       NotifyAccess=
810           Controls access to the service status notification socket, as
811           accessible via the sd_notify(3) call. Takes one of none (the
812           default), main, exec or all. If none, no daemon status updates are
813           accepted from the service processes, all status update messages are
814           ignored. If main, only service updates sent from the main process
815           of the service are accepted. If exec, only service updates sent
816           from any of the main or control processes originating from one of
817           the Exec*= commands are accepted. If all, all services updates from
818           all members of the service's control group are accepted. This
819           option should be set to open access to the notification socket when
820           using Type=notify or WatchdogSec= (see above). If those options are
821           used but NotifyAccess= is not configured, it will be implicitly set
822           to main.
823
824           Note that sd_notify() notifications may be attributed to units
825           correctly only if either the sending process is still around at the
826           time PID 1 processes the message, or if the sending process is
827           explicitly runtime-tracked by the service manager. The latter is
828           the case if the service manager originally forked off the process,
829           i.e. on all processes that match main or exec. Conversely, if an
830           auxiliary process of the unit sends an sd_notify() message and
831           immediately exits, the service manager might not be able to
832           properly attribute the message to the unit, and thus will ignore
833           it, even if NotifyAccess=all is set for it.
834
835       Sockets=
836           Specifies the name of the socket units this service shall inherit
837           socket file descriptors from when the service is started. Normally,
838           it should not be necessary to use this setting, as all socket file
839           descriptors whose unit shares the same name as the service (subject
840           to the different unit name suffix of course) are passed to the
841           spawned process.
842
843           Note that the same socket file descriptors may be passed to
844           multiple processes simultaneously. Also note that a different
845           service may be activated on incoming socket traffic than the one
846           which is ultimately configured to inherit the socket file
847           descriptors. Or, in other words: the Service= setting of .socket
848           units does not have to match the inverse of the Sockets= setting of
849           the .service it refers to.
850
851           This option may appear more than once, in which case the list of
852           socket units is merged. Note that once set, clearing the list of
853           sockets again (for example, by assigning the empty string to this
854           option) is not supported.
855
856       FileDescriptorStoreMax=
857           Configure how many file descriptors may be stored in the service
858           manager for the service using sd_pid_notify_with_fds(3)'s
859           "FDSTORE=1" messages. This is useful for implementing services that
860           can restart after an explicit request or a crash without losing
861           state. Any open sockets and other file descriptors which should not
862           be closed during the restart may be stored this way. Application
863           state can either be serialized to a file in /run, or better, stored
864           in a memfd_create(2) memory file descriptor. Defaults to 0, i.e. no
865           file descriptors may be stored in the service manager. All file
866           descriptors passed to the service manager from a specific service
867           are passed back to the service's main process on the next service
868           restart. Any file descriptors passed to the service manager are
869           automatically closed when POLLHUP or POLLERR is seen on them, or
870           when the service is fully stopped and no job is queued or being
871           executed for it. If this option is used, NotifyAccess= (see above)
872           should be set to open access to the notification socket provided by
873           systemd. If NotifyAccess= is not set, it will be implicitly set to
874           main.
875
876       USBFunctionDescriptors=
877           Configure the location of a file containing USB FunctionFS[2]
878           descriptors, for implementation of USB gadget functions. This is
879           used only in conjunction with a socket unit with ListenUSBFunction=
880           configured. The contents of this file are written to the ep0 file
881           after it is opened.
882
883       USBFunctionStrings=
884           Configure the location of a file containing USB FunctionFS strings.
885           Behavior is similar to USBFunctionDescriptors= above.
886
887       OOMPolicy=
888           Configure the Out-Of-Memory (OOM) killer policy. On Linux, when
889           memory becomes scarce the kernel might decide to kill a running
890           process in order to free up memory and reduce memory pressure. This
891           setting takes one of continue, stop or kill. If set to continue and
892           a process of the service is killed by the kernel's OOM killer this
893           is logged but the service continues running. If set to stop the
894           event is logged but the service is terminated cleanly by the
895           service manager. If set to kill and one of the service's processes
896           is killed by the OOM killer the kernel is instructed to kill all
897           remaining processes of the service, too. Defaults to the setting
898           DefaultOOMPolicy= in system.conf(5) is set to, except for services
899           where Delegate= is turned on, where it defaults to continue.
900
901           Use the OOMScoreAdjust= setting to configure whether processes of
902           the unit shall be considered preferred or less preferred candidates
903           for process termination by the Linux OOM killer logic. See
904           systemd.exec(5) for details.
905
906       Check systemd.exec(5) and systemd.kill(5) for more settings.
907

COMMAND LINES

909       This section describes command line parsing and variable and specifier
910       substitutions for ExecStart=, ExecStartPre=, ExecStartPost=,
911       ExecReload=, ExecStop=, and ExecStopPost= options.
912
913       Multiple command lines may be concatenated in a single directive by
914       separating them with semicolons (these semicolons must be passed as
915       separate words). Lone semicolons may be escaped as "\;".
916
917       Each command line is split on whitespace, with the first item being the
918       command to execute, and the subsequent items being the arguments.
919       Double quotes ("...") and single quotes ('...') may be used to wrap a
920       whole item (the opening quote may appear only at the beginning or after
921       whitespace that is not quoted, and the closing quote must be followed
922       by whitespace or the end of line), in which case everything until the
923       next matching quote becomes part of the same argument. Quotes
924       themselves are removed. C-style escapes are also supported. The table
925       below contains the list of known escape patterns. Only escape patterns
926       which match the syntax in the table are allowed; other patterns may be
927       added in the future and unknown patterns will result in a warning. In
928       particular, any backslashes should be doubled. Finally, a trailing
929       backslash ("\") may be used to merge lines.
930
931       This syntax is inspired by shell syntax, but only the meta-characters
932       and expansions described in the following paragraphs are understood,
933       and the expansion of variables is different. Specifically, redirection
934       using "<", "<<", ">", and ">>", pipes using "|", running programs in
935       the background using "&", and other elements of shell syntax are not
936       supported.
937
938       The command to execute may contain spaces, but control characters are
939       not allowed.
940
941       The command line accepts "%" specifiers as described in
942       systemd.unit(5).
943
944       Basic environment variable substitution is supported. Use "${FOO}" as
945       part of a word, or as a word of its own, on the command line, in which
946       case it will be replaced by the value of the environment variable
947       including all whitespace it contains, resulting in a single argument.
948       Use "$FOO" as a separate word on the command line, in which case it
949       will be replaced by the value of the environment variable split at
950       whitespace, resulting in zero or more arguments. For this type of
951       expansion, quotes are respected when splitting into words, and
952       afterwards removed.
953
954       If the command is not a full (absolute) path, it will be resolved to a
955       full path using a fixed search path determinted at compilation time.
956       Searched directories include /usr/local/bin/, /usr/bin/, /bin/ on
957       systems using split /usr/bin/ and /bin/ directories, and their sbin/
958       counterparts on systems using split bin/ and sbin/. It is thus safe to
959       use just the executable name in case of executables located in any of
960       the "standard" directories, and an absolute path must be used in other
961       cases. Using an absolute path is recommended to avoid ambiguity. Hint:
962       this search path may be queried using systemd-path
963       search-binaries-default.
964
965       Example:
966
967           Environment="ONE=one" 'TWO=two two'
968           ExecStart=echo $ONE $TWO ${TWO}
969
970       This will execute /bin/echo with four arguments: "one", "two", "two",
971       and "two two".
972
973       Example:
974
975           Environment=ONE='one' "TWO='two two' too" THREE=
976           ExecStart=/bin/echo ${ONE} ${TWO} ${THREE}
977           ExecStart=/bin/echo $ONE $TWO $THREE
978
979       This results in /bin/echo being called twice, the first time with
980       arguments "'one'", "'two two' too", "", and the second time with
981       arguments "one", "two two", "too".
982
983       To pass a literal dollar sign, use "$$". Variables whose value is not
984       known at expansion time are treated as empty strings. Note that the
985       first argument (i.e. the program to execute) may not be a variable.
986
987       Variables to be used in this fashion may be defined through
988       Environment= and EnvironmentFile=. In addition, variables listed in the
989       section "Environment variables in spawned processes" in
990       systemd.exec(5), which are considered "static configuration", may be
991       used (this includes e.g.  $USER, but not $TERM).
992
993       Note that shell command lines are not directly supported. If shell
994       command lines are to be used, they need to be passed explicitly to a
995       shell implementation of some kind. Example:
996
997           ExecStart=sh -c 'dmesg | tac'
998
999       Example:
1000
1001           ExecStart=echo one ; echo "two two"
1002
1003       This will execute echo two times, each time with one argument: "one"
1004       and "two two", respectively. Because two commands are specified,
1005       Type=oneshot must be used.
1006
1007       Example:
1008
1009           ExecStart=echo / >/dev/null & \; \
1010           ls
1011
1012       This will execute echo with five arguments: "/", ">/dev/null", "&",
1013       ";", and "ls".
1014
1015       Table 3. C escapes supported in command lines and environment variables
1016       ┌────────┬─────────────────────────┐
1017Literal Actual value            
1018       ├────────┼─────────────────────────┤
1019       │"\a"    │ bell                    │
1020       ├────────┼─────────────────────────┤
1021       │"\b"    │ backspace               │
1022       ├────────┼─────────────────────────┤
1023       │"\f"    │ form feed               │
1024       ├────────┼─────────────────────────┤
1025       │"\n"    │ newline                 │
1026       ├────────┼─────────────────────────┤
1027       │"\r"    │ carriage return         │
1028       ├────────┼─────────────────────────┤
1029       │"\t"    │ tab                     │
1030       ├────────┼─────────────────────────┤
1031       │"\v"    │ vertical tab            │
1032       ├────────┼─────────────────────────┤
1033       │"\\"    │ backslash               │
1034       ├────────┼─────────────────────────┤
1035       │"\""    │ double quotation mark   │
1036       ├────────┼─────────────────────────┤
1037       │"\'"    │ single quotation mark   │
1038       ├────────┼─────────────────────────┤
1039       │"\s"    │ space                   │
1040       ├────────┼─────────────────────────┤
1041       │"\xxx"  │ character number xx in  │
1042       │        │ hexadecimal encoding    │
1043       ├────────┼─────────────────────────┤
1044       │"\nnn"  │ character number nnn in │
1045       │        │ octal encoding          │
1046       └────────┴─────────────────────────┘
1047

EXAMPLES

1049       Example 2. Simple service
1050
1051       The following unit file creates a service that will execute
1052       /usr/sbin/foo-daemon. Since no Type= is specified, the default
1053       Type=simple will be assumed. systemd will assume the unit to be started
1054       immediately after the program has begun executing.
1055
1056           [Unit]
1057           Description=Foo
1058
1059           [Service]
1060           ExecStart=/usr/sbin/foo-daemon
1061
1062           [Install]
1063           WantedBy=multi-user.target
1064
1065       Note that systemd assumes here that the process started by systemd will
1066       continue running until the service terminates. If the program
1067       daemonizes itself (i.e. forks), please use Type=forking instead.
1068
1069       Since no ExecStop= was specified, systemd will send SIGTERM to all
1070       processes started from this service, and after a timeout also SIGKILL.
1071       This behavior can be modified, see systemd.kill(5) for details.
1072
1073       Note that this unit type does not include any type of notification when
1074       a service has completed initialization. For this, you should use other
1075       unit types, such as Type=notify if the service understands systemd's
1076       notification protocol, Type=forking if the service can background
1077       itself or Type=dbus if the unit acquires a DBus name once
1078       initialization is complete. See below.
1079
1080       Example 3. Oneshot service
1081
1082       Sometimes, units should just execute an action without keeping active
1083       processes, such as a filesystem check or a cleanup action on boot. For
1084       this, Type=oneshot exists. Units of this type will wait until the
1085       process specified terminates and then fall back to being inactive. The
1086       following unit will perform a cleanup action:
1087
1088           [Unit]
1089           Description=Cleanup old Foo data
1090
1091           [Service]
1092           Type=oneshot
1093           ExecStart=/usr/sbin/foo-cleanup
1094
1095           [Install]
1096           WantedBy=multi-user.target
1097
1098       Note that systemd will consider the unit to be in the state "starting"
1099       until the program has terminated, so ordered dependencies will wait for
1100       the program to finish before starting themselves. The unit will revert
1101       to the "inactive" state after the execution is done, never reaching the
1102       "active" state. That means another request to start the unit will
1103       perform the action again.
1104
1105       Type=oneshot are the only service units that may have more than one
1106       ExecStart= specified. For units with multiple commands (Type=oneshot),
1107       all commands will be run again.
1108
1109       For Type=oneshot, Restart=always and Restart=on-success are not
1110       allowed.
1111
1112       Example 4. Stoppable oneshot service
1113
1114       Similarly to the oneshot services, there are sometimes units that need
1115       to execute a program to set up something and then execute another to
1116       shut it down, but no process remains active while they are considered
1117       "started". Network configuration can sometimes fall into this category.
1118       Another use case is if a oneshot service shall not be executed each
1119       time when they are pulled in as a dependency, but only the first time.
1120
1121       For this, systemd knows the setting RemainAfterExit=yes, which causes
1122       systemd to consider the unit to be active if the start action exited
1123       successfully. This directive can be used with all types, but is most
1124       useful with Type=oneshot and Type=simple. With Type=oneshot, systemd
1125       waits until the start action has completed before it considers the unit
1126       to be active, so dependencies start only after the start action has
1127       succeeded. With Type=simple, dependencies will start immediately after
1128       the start action has been dispatched. The following unit provides an
1129       example for a simple static firewall.
1130
1131           [Unit]
1132           Description=Simple firewall
1133
1134           [Service]
1135           Type=oneshot
1136           RemainAfterExit=yes
1137           ExecStart=/usr/local/sbin/simple-firewall-start
1138           ExecStop=/usr/local/sbin/simple-firewall-stop
1139
1140           [Install]
1141           WantedBy=multi-user.target
1142
1143       Since the unit is considered to be running after the start action has
1144       exited, invoking systemctl start on that unit again will cause no
1145       action to be taken.
1146
1147       Example 5. Traditional forking services
1148
1149       Many traditional daemons/services background (i.e. fork, daemonize)
1150       themselves when starting. Set Type=forking in the service's unit file
1151       to support this mode of operation. systemd will consider the service to
1152       be in the process of initialization while the original program is still
1153       running. Once it exits successfully and at least a process remains (and
1154       RemainAfterExit=no), the service is considered started.
1155
1156       Often, a traditional daemon only consists of one process. Therefore, if
1157       only one process is left after the original process terminates, systemd
1158       will consider that process the main process of the service. In that
1159       case, the $MAINPID variable will be available in ExecReload=,
1160       ExecStop=, etc.
1161
1162       In case more than one process remains, systemd will be unable to
1163       determine the main process, so it will not assume there is one. In that
1164       case, $MAINPID will not expand to anything. However, if the process
1165       decides to write a traditional PID file, systemd will be able to read
1166       the main PID from there. Please set PIDFile= accordingly. Note that the
1167       daemon should write that file before finishing with its initialization.
1168       Otherwise, systemd might try to read the file before it exists.
1169
1170       The following example shows a simple daemon that forks and just starts
1171       one process in the background:
1172
1173           [Unit]
1174           Description=Some simple daemon
1175
1176           [Service]
1177           Type=forking
1178           ExecStart=/usr/sbin/my-simple-daemon -d
1179
1180           [Install]
1181           WantedBy=multi-user.target
1182
1183       Please see systemd.kill(5) for details on how you can influence the way
1184       systemd terminates the service.
1185
1186       Example 6. DBus services
1187
1188       For services that acquire a name on the DBus system bus, use Type=dbus
1189       and set BusName= accordingly. The service should not fork (daemonize).
1190       systemd will consider the service to be initialized once the name has
1191       been acquired on the system bus. The following example shows a typical
1192       DBus service:
1193
1194           [Unit]
1195           Description=Simple DBus service
1196
1197           [Service]
1198           Type=dbus
1199           BusName=org.example.simple-dbus-service
1200           ExecStart=/usr/sbin/simple-dbus-service
1201
1202           [Install]
1203           WantedBy=multi-user.target
1204
1205       For bus-activatable services, do not include a "[Install]" section in
1206       the systemd service file, but use the SystemdService= option in the
1207       corresponding DBus service file, for example
1208       (/usr/share/dbus-1/system-services/org.example.simple-dbus-service.service):
1209
1210           [D-BUS Service]
1211           Name=org.example.simple-dbus-service
1212           Exec=/usr/sbin/simple-dbus-service
1213           User=root
1214           SystemdService=simple-dbus-service.service
1215
1216       Please see systemd.kill(5) for details on how you can influence the way
1217       systemd terminates the service.
1218
1219       Example 7. Services that notify systemd about their initialization
1220
1221       Type=simple services are really easy to write, but have the major
1222       disadvantage of systemd not being able to tell when initialization of
1223       the given service is complete. For this reason, systemd supports a
1224       simple notification protocol that allows daemons to make systemd aware
1225       that they are done initializing. Use Type=notify for this. A typical
1226       service file for such a daemon would look like this:
1227
1228           [Unit]
1229           Description=Simple notifying service
1230
1231           [Service]
1232           Type=notify
1233           ExecStart=/usr/sbin/simple-notifying-service
1234
1235           [Install]
1236           WantedBy=multi-user.target
1237
1238       Note that the daemon has to support systemd's notification protocol,
1239       else systemd will think the service has not started yet and kill it
1240       after a timeout. For an example of how to update daemons to support
1241       this protocol transparently, take a look at sd_notify(3). systemd will
1242       consider the unit to be in the 'starting' state until a readiness
1243       notification has arrived.
1244
1245       Please see systemd.kill(5) for details on how you can influence the way
1246       systemd terminates the service.
1247

SEE ALSO

1249       systemd(1), systemctl(1), systemd-system.conf(5), systemd.unit(5),
1250       systemd.exec(5), systemd.resource-control(5), systemd.kill(5),
1251       systemd.directives(7), systemd-run(1)
1252

NOTES

1254        1. Incompatibilities with SysV
1255           https://www.freedesktop.org/wiki/Software/systemd/Incompatibilities
1256
1257        2. USB FunctionFS
1258           https://www.kernel.org/doc/Documentation/usb/functionfs.txt
1259
1260
1261
1262systemd 245                                                 SYSTEMD.SERVICE(5)
Impressum