{
    "mode": "man",
    "parameter": "systemd.service",
    "section": "5",
    "url": "https://www.chedong.com/phpMan.php/man/systemd.service/5/json",
    "generated": "2026-06-12T03:39:41Z",
    "synopsis": "service.service",
    "sections": {
        "NAME": {
            "content": "systemd.service - Service unit configuration\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "service.service\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "A unit configuration file whose name ends in \".service\" encodes information about a process\ncontrolled and supervised by systemd.\n\nThis man page lists the configuration options specific to this unit type. See systemd.unit(5)\nfor the common options of all unit configuration files. The common configuration items are\nconfigured in the generic [Unit] and [Install] sections. The service specific configuration\noptions are configured in the [Service] section.\n\nAdditional options are listed in systemd.exec(5), which define the execution environment the\ncommands are executed in, and in systemd.kill(5), which define the way the processes of the\nservice are terminated, and in systemd.resource-control(5), which configure resource control\nsettings for the processes of the service.\n\nIf a service is requested under a certain name but no unit configuration file is found,\nsystemd looks for a SysV init script by the same name (with the .service suffix removed) and\ndynamically creates a service unit from that script. This is useful for compatibility with\nSysV. Note that this compatibility is quite comprehensive but not 100%. For details about the\nincompatibilities, see the Incompatibilities with SysV[1] document.\n\nThe systemd-run(1) command allows creating .service and .scope units dynamically and\ntransiently from the command line.\n",
            "subsections": []
        },
        "SERVICE TEMPLATES": {
            "content": "It is possible for systemd services to take a single argument via the\n\"service@argument.service\" syntax. Such services are called \"instantiated\" services, while\nthe unit definition without the argument parameter is called a \"template\". An example could\nbe a dhcpcd@.service service template which takes a network interface as a parameter to form\nan instantiated service. Within the service file, this parameter or \"instance name\" can be\naccessed with %-specifiers. See systemd.unit(5) for details.\n",
            "subsections": []
        },
        "AUTOMATIC DEPENDENCIES": {
            "content": "",
            "subsections": [
                {
                    "name": "Implicit Dependencies",
                    "content": "The following dependencies are implicitly added:\n\n•   Services with Type=dbus set automatically acquire dependencies of type Requires= and\nAfter= on dbus.socket.\n\n•   Socket activated services are automatically ordered after their activating .socket units\nvia an automatic After= dependency. Services also pull in all .socket units listed in\nSockets= via automatic Wants= and After= dependencies.\n\nAdditional implicit dependencies may be added as result of execution and resource control\nparameters as documented in systemd.exec(5) and systemd.resource-control(5).\n"
                },
                {
                    "name": "Default Dependencies",
                    "content": "The following dependencies are added unless DefaultDependencies=no is set:\n\n•   Service units will have dependencies of type Requires= and After= on sysinit.target, a\ndependency of type After= on basic.target as well as dependencies of type Conflicts= and\nBefore= on shutdown.target. These ensure that normal service units pull in basic system\ninitialization, and are terminated cleanly prior to system shutdown. Only services\ninvolved with early boot or late system shutdown should disable this option.\n\n•   Instanced service units (i.e. service units with an \"@\" in their name) are assigned by\ndefault a per-template slice unit (see systemd.slice(5)), named after the template unit,\ncontaining all instances of the specific template. This slice is normally stopped at\nshutdown, together with all template instances. If that is not desired, set\nDefaultDependencies=no in the template unit, and either define your own per-template\nslice unit file that also sets DefaultDependencies=no, or set Slice=system.slice (or\nanother suitable slice) in the template unit. Also see systemd.resource-control(5).\n"
                }
            ]
        },
        "OPTIONS": {
            "content": "Service files must include a [Service] section, which carries information about the service\nand the process it supervises. A number of options that may be used in this section are\nshared with other unit types. These options are documented in systemd.exec(5),\nsystemd.kill(5) and systemd.resource-control(5). The options specific to the [Service]\nsection of service units are the following:\n\nType=\nConfigures the process start-up type for this service unit. One of simple, exec, forking,\noneshot, dbus, notify or idle:\n\n•   If set to simple (the default if ExecStart= is specified but neither Type= nor\nBusName= are), the service manager will consider the unit started immediately after\nthe main service process has been forked off. It is expected that the process\nconfigured with ExecStart= is the main process of the service. In this mode, if the\nprocess offers functionality to other processes on the system, its communication\nchannels should be installed before the service is started up (e.g. sockets set up by\nsystemd, via socket activation), as the service manager will immediately proceed\nstarting follow-up units, right after creating the main service process, and before\nexecuting the service's binary. Note that this means systemctl start command lines\nfor simple services will report success even if the service's binary cannot be\ninvoked successfully (for example because the selected User= doesn't exist, or the\nservice binary is missing).\n\n•   The exec type is similar to simple, but the service manager will consider the unit\nstarted immediately after the main service binary has been executed. The service\nmanager will delay starting of follow-up units until that point. (Or in other words:\nsimple proceeds with further jobs right after fork() returns, while exec will not\nproceed before both fork() and execve() in the service process succeeded.) Note that\nthis means systemctl start command lines for exec services will report failure when\nthe service's binary cannot be invoked successfully (for example because the selected\nUser= doesn't exist, or the service binary is missing).\n\n•   If set to forking, it is expected that the process configured with ExecStart= will\ncall fork() as part of its start-up. The parent process is expected to exit when\nstart-up is complete and all communication channels are set up. The child continues\nto run as the main service process, and the service manager will consider the unit\nstarted when the parent process exits. This is the behavior of traditional UNIX\nservices. If this setting is used, it is recommended to also use the PIDFile= option,\nso that systemd can reliably identify the main process of the service. systemd will\nproceed with starting follow-up units as soon as the parent process exits.\n\n•   Behavior of oneshot is similar to simple; however, the service manager will consider\nthe unit up after the main process exits. It will then start follow-up units.\nRemainAfterExit= is particularly useful for this type of service.  Type=oneshot is\nthe implied default if neither Type= nor ExecStart= are specified. Note that if this\noption is used without RemainAfterExit= the service will never enter \"active\" unit\nstate, but directly transition from \"activating\" to \"deactivating\" or \"dead\" since no\nprocess is configured that shall run continuously. In particular this means that\nafter a service of this type ran (and which has RemainAfterExit= not set) it will not\nshow up as started afterwards, but as dead.\n\n•   Behavior of dbus is similar to simple; however, it is expected that the service\nacquires a name on the D-Bus bus, as configured by BusName=. systemd will proceed\nwith starting follow-up units after the D-Bus bus name has been acquired. Service\nunits with this option configured implicitly gain dependencies on the dbus.socket\nunit. This type is the default if BusName= is specified. A service unit of this type\nis considered to be in the activating state until the specified bus name is acquired.\nIt is considered activated while the bus name is taken. Once the bus name is released\nthe service is considered being no longer functional which has the effect that the\nservice manager attempts to terminate any remaining processes belonging to the\nservice. Services that drop their bus name as part of their shutdown logic thus\nshould be prepared to receive a SIGTERM (or whichever signal is configured in\nKillSignal=) as result.\n\n•   Behavior of notify is similar to exec; however, it is expected that the service sends\na notification message via sdnotify(3) or an equivalent call when it has finished\nstarting up. systemd will proceed with starting follow-up units after this\nnotification message has been sent. If this option is used, NotifyAccess= (see below)\nshould be set to open access to the notification socket provided by systemd. If\nNotifyAccess= is missing or set to none, it will be forcibly set to main.\n\n•   Behavior of idle is very similar to simple; however, actual execution of the service\nprogram is delayed until all active jobs are dispatched. This may be used to avoid\ninterleaving of output of shell services with the status output on the console. Note\nthat this type is useful only to improve console output, it is not useful as a\ngeneral unit ordering tool, and the effect of this service type is subject to a 5s\ntimeout, after which the service program is invoked anyway.\n\nIt is generally recommended to use Type=simple for long-running services whenever\npossible, as it is the simplest and fastest option. However, as this service type won't\npropagate service start-up failures and doesn't allow ordering of other units against\ncompletion of initialization of the service (which for example is useful if clients need\nto connect to the service through some form of IPC, and the IPC channel is only\nestablished by the service itself — in contrast to doing this ahead of time through\nsocket or bus activation or similar), it might not be sufficient for many cases. If so,\nnotify or dbus (the latter only in case the service provides a D-Bus interface) are the\npreferred options as they allow service program code to precisely schedule when to\nconsider the service started up successfully and when to proceed with follow-up units.\nThe notify service type requires explicit support in the service codebase (as sdnotify()\nor an equivalent API needs to be invoked by the service at the appropriate time) — if\nit's not supported, then forking is an alternative: it supports the traditional UNIX\nservice start-up protocol. Finally, exec might be an option for cases where it is enough\nto ensure the service binary is invoked, and where the service binary itself executes no\nor little initialization on its own (and its initialization is unlikely to fail). Note\nthat using any type other than simple possibly delays the boot process, as the service\nmanager needs to wait for service initialization to complete. It is hence recommended not\nto needlessly use any types other than simple. (Also note it is generally not recommended\nto use idle or oneshot for long-running services.)\n\nRemainAfterExit=\nTakes a boolean value that specifies whether the service shall be considered active even\nwhen all its processes exited. Defaults to no.\n\nGuessMainPID=\nTakes a boolean value that specifies whether systemd should try to guess the main PID of\na service if it cannot be determined reliably. This option is ignored unless Type=forking\nis set and PIDFile= is unset because for the other types or with an explicitly configured\nPID file, the main PID is always known. The guessing algorithm might come to incorrect\nconclusions if a daemon consists of more than one process. If the main PID cannot be\ndetermined, failure detection and automatic restarting of a service will not work\nreliably. Defaults to yes.\n\nPIDFile=\nTakes a path referring to the PID file of the service. Usage of this option is\nrecommended for services where Type= is set to forking. The path specified typically\npoints to a file below /run/. If a relative path is specified it is hence prefixed with\n/run/. The service manager will read the PID of the main process of the service from this\nfile after start-up of the service. The service manager will not write to the file\nconfigured here, although it will remove the file after the service has shut down if it\nstill exists. The PID file does not need to be owned by a privileged user, but if it is\nowned by an unprivileged user additional safety restrictions are enforced: the file may\nnot be a symlink to a file owned by a different user (neither directly nor indirectly),\nand the PID file must refer to a process already belonging to the service.\n\nNote that PID files should be avoided in modern projects. Use Type=notify or Type=simple\nwhere possible, which does not require use of PID files to determine the main process of\na service and avoids needless forking.\n\nBusName=\nTakes a D-Bus destination name that this service shall use. This option is mandatory for\nservices where Type= is set to dbus. It is recommended to always set this property if\nknown to make it easy to map the service name to the D-Bus destination. In particular,\nsystemctl service-log-level/service-log-target verbs make use of this.\n\nExecStart=\nCommands with their arguments that are executed when this service is started. The value\nis split into zero or more command lines according to the rules described below (see\nsection \"Command Lines\" below).\n\nUnless Type= is oneshot, exactly one command must be given. When Type=oneshot is used,\nzero or more commands may be specified. Commands may be specified by providing multiple\ncommand lines in the same directive, or alternatively, this directive may be specified\nmore than once with the same effect. If the empty string is assigned to this option, the\nlist of commands to start is reset, prior assignments of this option will have no effect.\nIf no ExecStart= is specified, then the service must have RemainAfterExit=yes and at\nleast one ExecStop= line set. (Services lacking both ExecStart= and ExecStop= are not\nvalid.)\n\nFor each of the specified commands, the first argument must be either an absolute path to\nan executable or a simple file name without any slashes. Optionally, this filename may be\nprefixed with a number of special characters:\n\nTable 1. Special executable prefixes\n┌───────┬───────────────────────────────────┐\n│Prefix │ Effect                            │\n├───────┼───────────────────────────────────┤\n│\"@\"    │ If the executable path is         │\n│       │ prefixed with \"@\", the second     │\n│       │ specified token will be passed as │\n│       │ \"argv[0]\" to the executed process │\n│       │ (instead of the actual filename), │\n│       │ followed by the further arguments │\n│       │ specified.                        │\n├───────┼───────────────────────────────────┤\n│\"-\"    │ If the executable path is         │\n│       │ prefixed with \"-\", an exit code   │\n│       │ of the command normally           │\n│       │ considered a failure (i.e.        │\n│       │ non-zero exit status or abnormal  │\n│       │ exit due to signal) is recorded,  │\n│       │ but has no further effect and is  │\n│       │ considered equivalent to success. │\n├───────┼───────────────────────────────────┤\n│\":\"    │ If the executable path is         │\n│       │ prefixed with \":\", environment    │\n│       │ variable substitution (as         │\n│       │ described by the \"Command Lines\"  │\n│       │ section below) is not applied.    │\n├───────┼───────────────────────────────────┤\n│\"+\"    │ If the executable path is         │\n│       │ prefixed with \"+\" then the        │\n│       │ process is executed with full     │\n│       │ privileges. In this mode          │\n│       │ privilege restrictions configured │\n│       │ with User=, Group=,               │\n│       │ CapabilityBoundingSet= or the     │\n│       │ various file system namespacing   │\n│       │ options (such as PrivateDevices=, │\n│       │ PrivateTmp=) are not applied to   │\n│       │ the invoked command line (but     │\n│       │ still affect any other            │\n│       │ ExecStart=, ExecStop=, ...        │\n│       │ lines).                           │\n├───────┼───────────────────────────────────┤\n│\"!\"    │ Similar to the \"+\" character      │\n│       │ discussed above this permits      │\n│       │ invoking command lines with       │\n│       │ elevated privileges. However,     │\n│       │ unlike \"+\" the \"!\" character      │\n│       │ exclusively alters the effect of  │\n│       │ User=, Group= and                 │\n│       │ SupplementaryGroups=, i.e. only   │\n│       │ the stanzas that affect user and  │\n│       │ group credentials. Note that this │\n│       │ setting may be combined with      │\n│       │ DynamicUser=, in which case a     │\n│       │ dynamic user/group pair is        │\n│       │ allocated before the command is   │\n│       │ invoked, but credential changing  │\n│       │ is left to the executed process   │\n│       │ itself.                           │\n├───────┼───────────────────────────────────┤\n│\"!!\"   │ This prefix is very similar to    │\n│       │ \"!\", however it only has an       │\n│       │ effect on systems lacking support │\n│       │ for ambient process capabilities, │\n│       │ i.e. without support for          │\n│       │ AmbientCapabilities=. It's        │\n│       │ intended to be used for unit      │\n│       │ files that take benefit of        │\n│       │ ambient capabilities to run       │\n│       │ processes with minimal privileges │\n│       │ wherever possible while remaining │\n│       │ compatible with systems that lack │\n│       │ ambient capabilities support.     │\n│       │ Note that when \"!!\" is used, and  │\n│       │ a system lacking ambient          │\n│       │ capability support is detected    │\n│       │ any configured SystemCallFilter=  │\n│       │ and CapabilityBoundingSet=        │\n│       │ stanzas are implicitly modified,  │\n│       │ in order to permit spawned        │\n│       │ processes to drop credentials and │\n│       │ capabilities themselves, even if  │\n│       │ this is configured to not be      │\n│       │ allowed. Moreover, if this prefix │\n│       │ is used and a system lacking      │\n│       │ ambient capability support is     │\n│       │ detected AmbientCapabilities=     │\n│       │ will be skipped and not be        │\n│       │ applied. On systems supporting    │\n│       │ ambient capabilities, \"!!\" has no │\n│       │ effect and is redundant.          │\n└───────┴───────────────────────────────────┘\n\"@\", \"-\", \":\", and one of \"+\"/\"!\"/\"!!\"  may be used together and they can appear in any\norder. However, only one of \"+\", \"!\", \"!!\"  may be used at a time. Note that these\nprefixes are also supported for the other command line settings, i.e.  ExecStartPre=,\nExecStartPost=, ExecReload=, ExecStop= and ExecStopPost=.\n\nIf more than one command is specified, the commands are invoked sequentially in the order\nthey appear in the unit file. If one of the commands fails (and is not prefixed with\n\"-\"), other lines are not executed, and the unit is considered failed.\n\nUnless Type=forking is set, the process started via this command line will be considered\nthe main process of the daemon.\n\nExecStartPre=, ExecStartPost=\nAdditional commands that are executed before or after the command in ExecStart=,\nrespectively. Syntax is the same as for ExecStart=, except that multiple command lines\nare allowed and the commands are executed one after the other, serially.\n\nIf any of those commands (not prefixed with \"-\") fail, the rest are not executed and the\nunit is considered failed.\n\nExecStart= commands are only run after all ExecStartPre= commands that were not prefixed\nwith a \"-\" exit successfully.\n\nExecStartPost= commands are only run after the commands specified in ExecStart= have been\ninvoked successfully, as determined by Type= (i.e. the process has been started for\nType=simple or Type=idle, the last ExecStart= process exited successfully for\nType=oneshot, the initial process exited successfully for Type=forking, \"READY=1\" is sent\nfor Type=notify, or the BusName= has been taken for Type=dbus).\n\nNote that ExecStartPre= may not be used to start long-running processes. All processes\nforked off by processes invoked via ExecStartPre= will be killed before the next service\nprocess is run.\n\nNote that if any of the commands specified in ExecStartPre=, ExecStart=, or\nExecStartPost= fail (and are not prefixed with \"-\", see above) or time out before the\nservice is fully up, execution continues with commands specified in ExecStopPost=, the\ncommands in ExecStop= are skipped.\n\nNote that the execution of ExecStartPost= is taken into account for the purpose of\nBefore=/After= ordering constraints.\n\nExecCondition=\nOptional commands that are executed before the command(s) in ExecStartPre=. Syntax is the\nsame as for ExecStart=, except that multiple command lines are allowed and the commands\nare executed one after the other, serially.\n\nThe behavior is like an ExecStartPre= and condition check hybrid: when an ExecCondition=\ncommand exits with exit code 1 through 254 (inclusive), the remaining commands are\nskipped and the unit is not marked as failed. However, if an ExecCondition= command exits\nwith 255 or abnormally (e.g. timeout, killed by a signal, etc.), the unit will be\nconsidered failed (and remaining commands will be skipped). Exit code of 0 or those\nmatching SuccessExitStatus= will continue execution to the next command(s).\n\nThe same recommendations about not running long-running processes in ExecStartPre= also\napplies to ExecCondition=.  ExecCondition= will also run the commands in ExecStopPost=,\nas part of stopping the service, in the case of any non-zero or abnormal exits, like the\nones described above.\n\nExecReload=\nCommands to execute to trigger a configuration reload in the service. This argument takes\nmultiple command lines, following the same scheme as described for ExecStart= above. Use\nof this setting is optional. Specifier and environment variable substitution is supported\nhere following the same scheme as for ExecStart=.\n\nOne additional, special environment variable is set: if known, $MAINPID is set to the\nmain process of the daemon, and may be used for command lines like the following:\n\nExecReload=kill -HUP $MAINPID\n\nNote however that reloading a daemon by sending a signal (as with the example line above)\nis usually not a good choice, because this is an asynchronous operation and hence not\nsuitable to order reloads of multiple services against each other. It is strongly\nrecommended to set ExecReload= to a command that not only triggers a configuration reload\nof the daemon, but also synchronously waits for it to complete. For example, dbus-\nbroker(1) uses the following:\n\nExecReload=busctl call org.freedesktop.DBus \\\n/org/freedesktop/DBus org.freedesktop.DBus \\\nReloadConfig\n\nExecStop=\nCommands to execute to stop the service started via ExecStart=. This argument takes\nmultiple command lines, following the same scheme as described for ExecStart= above. Use\nof this setting is optional. After the commands configured in this option are run, it is\nimplied that the service is stopped, and any processes remaining for it are terminated\naccording to the KillMode= setting (see systemd.kill(5)). If this option is not\nspecified, the process is terminated by sending the signal specified in KillSignal= or\nRestartKillSignal= when service stop is requested. Specifier and environment variable\nsubstitution is supported (including $MAINPID, see above).\n\nNote that it is usually not sufficient to specify a command for this setting that only\nasks the service to terminate (for example, by sending some form of termination signal to\nit), but does not wait for it to do so. Since the remaining processes of the services are\nkilled according to KillMode= and KillSignal= or RestartKillSignal= as described above\nimmediately after the command exited, this may not result in a clean stop. The specified\ncommand should hence be a synchronous operation, not an asynchronous one.\n\nNote that the commands specified in ExecStop= are only executed when the service started\nsuccessfully first. They are not invoked if the service was never started at all, or in\ncase its start-up failed, for example because any of the commands specified in\nExecStart=, ExecStartPre= or ExecStartPost= failed (and weren't prefixed with \"-\", see\nabove) or timed out. Use ExecStopPost= to invoke commands when a service failed to start\nup correctly and is shut down again. Also note that the stop operation is always\nperformed if the service started successfully, even if the processes in the service\nterminated on their own or were killed. The stop commands must be prepared to deal with\nthat case.  $MAINPID will be unset if systemd knows that the main process exited by the\ntime the stop commands are called.\n\nService restart requests are implemented as stop operations followed by start operations.\nThis means that ExecStop= and ExecStopPost= are executed during a service restart\noperation.\n\nIt is recommended to use this setting for commands that communicate with the service\nrequesting clean termination. For post-mortem clean-up steps use ExecStopPost= instead.\n\nExecStopPost=\nAdditional commands that are executed after the service is stopped. This includes cases\nwhere the commands configured in ExecStop= were used, where the service does not have any\nExecStop= defined, or where the service exited unexpectedly. This argument takes multiple\ncommand lines, following the same scheme as described for ExecStart=. Use of these\nsettings is optional. Specifier and environment variable substitution is supported. Note\nthat – unlike ExecStop= – commands specified with this setting are invoked when a service\nfailed to start up correctly and is shut down again.\n\nIt is recommended to use this setting for clean-up operations that shall be executed even\nwhen the service failed to start up correctly. Commands configured with this setting need\nto be able to operate even if the service failed starting up half-way and left\nincompletely initialized data around. As the service's processes have been terminated\nalready when the commands specified with this setting are executed they should not\nattempt to communicate with them.\n\nNote that all commands that are configured with this setting are invoked with the result\ncode of the service, as well as the main process' exit code and status, set in the\n$SERVICERESULT, $EXITCODE and $EXITSTATUS environment variables, see systemd.exec(5)\nfor details.\n\nNote that the execution of ExecStopPost= is taken into account for the purpose of\nBefore=/After= ordering constraints.\n\nRestartSec=\nConfigures the time to sleep before restarting a service (as configured with Restart=).\nTakes a unit-less value in seconds, or a time span value such as \"5min 20s\". Defaults to\n100ms.\n\nTimeoutStartSec=\nConfigures the time to wait for start-up. If a daemon service does not signal start-up\ncompletion within the configured time, the service will be considered failed and will be\nshut down again. The precise action depends on the TimeoutStartFailureMode= option. Takes\na unit-less value in seconds, or a time span value such as \"5min 20s\". Pass \"infinity\" to\ndisable the timeout logic. Defaults to DefaultTimeoutStartSec= from the manager\nconfiguration file, except when Type=oneshot is used, in which case the timeout is\ndisabled by default (see systemd-system.conf(5)).\n\nIf a service of Type=notify sends \"EXTENDTIMEOUTUSEC=...\", this may cause the start\ntime to be extended beyond TimeoutStartSec=. The first receipt of this message must occur\nbefore TimeoutStartSec= is exceeded, and once the start time has extended beyond\nTimeoutStartSec=, the service manager will allow the service to continue to start,\nprovided the service repeats \"EXTENDTIMEOUTUSEC=...\"  within the interval specified\nuntil the service startup status is finished by \"READY=1\". (see sdnotify(3)).\n\nTimeoutStopSec=\nThis option serves two purposes. First, it configures the time to wait for each ExecStop=\ncommand. If any of them times out, subsequent ExecStop= commands are skipped and the\nservice will be terminated by SIGTERM. If no ExecStop= commands are specified, the\nservice gets the SIGTERM immediately. This default behavior can be changed by the\nTimeoutStopFailureMode= option. Second, it configures the time to wait for the service\nitself to stop. If it doesn't terminate in the specified time, it will be forcibly\nterminated by SIGKILL (see KillMode= in systemd.kill(5)). Takes a unit-less value in\nseconds, or a time span value such as \"5min 20s\". Pass \"infinity\" to disable the timeout\nlogic. Defaults to DefaultTimeoutStopSec= from the manager configuration file (see\nsystemd-system.conf(5)).\n\nIf a service of Type=notify sends \"EXTENDTIMEOUTUSEC=...\", this may cause the stop time\nto be extended beyond TimeoutStopSec=. The first receipt of this message must occur\nbefore TimeoutStopSec= is exceeded, and once the stop time has extended beyond\nTimeoutStopSec=, the service manager will allow the service to continue to stop, provided\nthe service repeats \"EXTENDTIMEOUTUSEC=...\"  within the interval specified, or\nterminates itself (see sdnotify(3)).\n\nTimeoutAbortSec=\nThis option configures the time to wait for the service to terminate when it was aborted\ndue to a watchdog timeout (see WatchdogSec=). If the service has a short TimeoutStopSec=\nthis option can be used to give the system more time to write a core dump of the service.\nUpon expiration the service will be forcibly terminated by SIGKILL (see KillMode= in\nsystemd.kill(5)). The core file will be truncated in this case. Use TimeoutAbortSec= to\nset a sensible timeout for the core dumping per service that is large enough to write all\nexpected data while also being short enough to handle the service failure in due time.\n\nTakes a unit-less value in seconds, or a time span value such as \"5min 20s\". Pass an\nempty value to skip the dedicated watchdog abort timeout handling and fall back\nTimeoutStopSec=. Pass \"infinity\" to disable the timeout logic. Defaults to\nDefaultTimeoutAbortSec= from the manager configuration file (see systemd-system.conf(5)).\n\nIf a service of Type=notify handles SIGABRT itself (instead of relying on the kernel to\nwrite a core dump) it can send \"EXTENDTIMEOUTUSEC=...\"  to extended the abort time\nbeyond TimeoutAbortSec=. The first receipt of this message must occur before\nTimeoutAbortSec= is exceeded, and once the abort time has extended beyond\nTimeoutAbortSec=, the service manager will allow the service to continue to abort,\nprovided the service repeats \"EXTENDTIMEOUTUSEC=...\"  within the interval specified, or\nterminates itself (see sdnotify(3)).\n\nTimeoutSec=\nA shorthand for configuring both TimeoutStartSec= and TimeoutStopSec= to the specified\nvalue.\n\nTimeoutStartFailureMode=, TimeoutStopFailureMode=\nThese options configure the action that is taken in case a daemon service does not signal\nstart-up within its configured TimeoutStartSec=, respectively if it does not stop within\nTimeoutStopSec=. Takes one of terminate, abort and kill. Both options default to\nterminate.\n\nIf terminate is set the service will be gracefully terminated by sending the signal\nspecified in KillSignal= (defaults to SIGTERM, see systemd.kill(5)). If the service does\nnot terminate the FinalKillSignal= is sent after TimeoutStopSec=. If abort is set,\nWatchdogSignal= is sent instead and TimeoutAbortSec= applies before sending\nFinalKillSignal=. This setting may be used to analyze services that fail to start-up or\nshut-down intermittently. By using kill the service is immediately terminated by sending\nFinalKillSignal= without any further timeout. This setting can be used to expedite the\nshutdown of failing services.\n\nRuntimeMaxSec=\nConfigures a maximum time for the service to run. If this is used and the service has\nbeen active for longer than the specified time it is terminated and put into a failure\nstate. Note that this setting does not have any effect on Type=oneshot services, as they\nterminate immediately after activation completed. Pass \"infinity\" (the default) to\nconfigure no runtime limit.\n\nIf a service of Type=notify sends \"EXTENDTIMEOUTUSEC=...\", this may cause the runtime\nto be extended beyond RuntimeMaxSec=. The first receipt of this message must occur before\nRuntimeMaxSec= is exceeded, and once the runtime has extended beyond RuntimeMaxSec=, the\nservice manager will allow the service to continue to run, provided the service repeats\n\"EXTENDTIMEOUTUSEC=...\"  within the interval specified until the service shutdown is\nachieved by \"STOPPING=1\" (or termination). (see sdnotify(3)).\n\nWatchdogSec=\nConfigures the watchdog timeout for a service. The watchdog is activated when the\nstart-up is completed. The service must call sdnotify(3) regularly with \"WATCHDOG=1\"\n(i.e. the \"keep-alive ping\"). If the time between two such calls is larger than the\nconfigured time, then the service is placed in a failed state and it will be terminated\nwith SIGABRT (or the signal specified by WatchdogSignal=). By setting Restart= to\non-failure, on-watchdog, on-abnormal or always, the service will be automatically\nrestarted. The time configured here will be passed to the executed service process in the\nWATCHDOGUSEC= environment variable. This allows daemons to automatically enable the\nkeep-alive pinging logic if watchdog support is enabled for the service. If this option\nis used, NotifyAccess= (see below) should be set to open access to the notification\nsocket provided by systemd. If NotifyAccess= is not set, it will be implicitly set to\nmain. Defaults to 0, which disables this feature. The service can check whether the\nservice manager expects watchdog keep-alive notifications. See sdwatchdogenabled(3) for\ndetails.  sdeventsetwatchdog(3) may be used to enable automatic watchdog notification\nsupport.\n\nRestart=\nConfigures whether the service shall be restarted when the service process exits, is\nkilled, or a timeout is reached. The service process may be the main service process, but\nit may also be one of the processes specified with ExecStartPre=, ExecStartPost=,\nExecStop=, ExecStopPost=, or ExecReload=. When the death of the process is a result of\nsystemd operation (e.g. service stop or restart), the service will not be restarted.\nTimeouts include missing the watchdog \"keep-alive ping\" deadline and a service start,\nreload, and stop operation timeouts.\n\nTakes one of no, on-success, on-failure, on-abnormal, on-watchdog, on-abort, or always.\nIf set to no (the default), the service will not be restarted. If set to on-success, it\nwill be restarted only when the service process exits cleanly. In this context, a clean\nexit means any of the following:\n\n•   exit code of 0;\n\n•   for types other than Type=oneshot, one of the signals SIGHUP, SIGINT, SIGTERM, or\nSIGPIPE;\n\n•   exit statuses and signals specified in SuccessExitStatus=.\n\nIf set to on-failure, the service will be restarted when the process exits with a\nnon-zero exit code, is terminated by a signal (including on core dump, but excluding the\naforementioned four signals), when an operation (such as service reload) times out, and\nwhen the configured watchdog timeout is triggered. If set to on-abnormal, the service\nwill be restarted when the process is terminated by a signal (including on core dump,\nexcluding the aforementioned four signals), when an operation times out, or when the\nwatchdog timeout is triggered. If set to on-abort, the service will be restarted only if\nthe service process exits due to an uncaught signal not specified as a clean exit status.\nIf set to on-watchdog, the service will be restarted only if the watchdog timeout for the\nservice expires. If set to always, the service will be restarted regardless of whether it\nexited cleanly or not, got terminated abnormally by a signal, or hit a timeout.\n\nTable 2. Exit causes and the effect of the Restart= settings\n┌──────────────┬────┬────────┬────────────┬────────────┬─────────────┬──────────┬─────────────┐\n│Restart       │ no │ always │ on-success │ on-failure │ on-abnormal │ on-abort │ on-watchdog │\n│settings/Exit │    │        │            │            │             │          │             │\n│causes        │    │        │            │            │             │          │             │\n├──────────────┼────┼────────┼────────────┼────────────┼─────────────┼──────────┼─────────────┤\n│Clean exit    │    │ X      │ X          │            │             │          │             │\n│code or       │    │        │            │            │             │          │             │\n│signal        │    │        │            │            │             │          │             │\n├──────────────┼────┼────────┼────────────┼────────────┼─────────────┼──────────┼─────────────┤\n│Unclean exit  │    │ X      │            │ X          │             │          │             │\n│code          │    │        │            │            │             │          │             │\n├──────────────┼────┼────────┼────────────┼────────────┼─────────────┼──────────┼─────────────┤\n│Unclean       │    │ X      │            │ X          │ X           │ X        │             │\n│signal        │    │        │            │            │             │          │             │\n├──────────────┼────┼────────┼────────────┼────────────┼─────────────┼──────────┼─────────────┤\n│Timeout       │    │ X      │            │ X          │ X           │          │             │\n├──────────────┼────┼────────┼────────────┼────────────┼─────────────┼──────────┼─────────────┤\n│Watchdog      │    │ X      │            │ X          │ X           │          │ X           │\n└──────────────┴────┴────────┴────────────┴────────────┴─────────────┴──────────┴─────────────┘\nAs exceptions to the setting above, the service will not be restarted if the exit code or\nsignal is specified in RestartPreventExitStatus= (see below) or the service is stopped\nwith systemctl stop or an equivalent operation. Also, the services will always be\nrestarted if the exit code or signal is specified in RestartForceExitStatus= (see below).\n\nNote that service restart is subject to unit start rate limiting configured with\nStartLimitIntervalSec= and StartLimitBurst=, see systemd.unit(5) for details. A restarted\nservice enters the failed state only after the start limits are reached.\n\nSetting this to on-failure is the recommended choice for long-running services, in order\nto increase reliability by attempting automatic recovery from errors. For services that\nshall be able to terminate on their own choice (and avoid immediate restarting),\non-abnormal is an alternative choice.\n\nSuccessExitStatus=\nTakes a list of exit status definitions that, when returned by the main service process,\nwill be considered successful termination, in addition to the normal successful exit\nstatus 0 and, except for Type=oneshot, the signals SIGHUP, SIGINT, SIGTERM, and SIGPIPE.\nExit status definitions can be numeric termination statuses, termination status names, or\ntermination signal names, separated by spaces. See the Process Exit Codes section in\nsystemd.exec(5) for a list of termination status names (for this setting only the part\nwithout the \"EXIT\" or \"EX\" prefix should be used). See signal(7) for a list of signal\nnames.\n\nNote that this setting does not change the mapping between numeric exit statuses and\ntheir names, i.e. regardless how this setting is used 0 will still be mapped to \"SUCCESS\"\n(and thus typically shown as \"0/SUCCESS\" in tool outputs) and 1 to \"FAILURE\" (and thus\ntypically shown as \"1/FAILURE\"), and so on. It only controls what happens as effect of\nthese exit statuses, and how it propagates to the state of the service as a whole.\n\nThis option may appear more than once, in which case the list of successful exit statuses\nis merged. If the empty string is assigned to this option, the list is reset, all prior\nassignments of this option will have no effect.\n\nExample 1. A service with the SuccessExitStatus= setting\n\nSuccessExitStatus=TEMPFAIL 250 SIGKILL\n\nExit status 75 (TEMPFAIL), 250, and the termination signal SIGKILL are considered clean\nservice terminations.\n\nNote: systemd-analyze exit-status may be used to list exit statuses and translate between\nnumerical status values and names.\n\nRestartPreventExitStatus=\nTakes a list of exit status definitions that, when returned by the main service process,\nwill prevent automatic service restarts, regardless of the restart setting configured\nwith Restart=. Exit status definitions can either be numeric exit codes or termination\nsignal names, and are separated by spaces. Defaults to the empty list, so that, by\ndefault, no exit status is excluded from the configured restart logic. For example:\n\nRestartPreventExitStatus=1 6 SIGABRT\n\nensures that exit codes 1 and 6 and the termination signal SIGABRT will not result in\nautomatic service restarting. This option may appear more than once, in which case the\nlist of restart-preventing statuses is merged. If the empty string is assigned to this\noption, the list is reset and all prior assignments of this option will have no effect.\n\nNote that this setting has no effect on processes configured via ExecStartPre=,\nExecStartPost=, ExecStop=, ExecStopPost= or ExecReload=, but only on the main service\nprocess, i.e. either the one invoked by ExecStart= or (depending on Type=, PIDFile=, ...)\nthe otherwise configured main process.\n\nRestartForceExitStatus=\nTakes a list of exit status definitions that, when returned by the main service process,\nwill force automatic service restarts, regardless of the restart setting configured with\nRestart=. The argument format is similar to RestartPreventExitStatus=.\n\nRootDirectoryStartOnly=\nTakes a boolean argument. If true, the root directory, as configured with the\nRootDirectory= option (see systemd.exec(5) for more information), is only applied to the\nprocess started with ExecStart=, and not to the various other ExecStartPre=,\nExecStartPost=, ExecReload=, ExecStop=, and ExecStopPost= commands. If false, the setting\nis applied to all configured commands the same way. Defaults to false.\n\nNonBlocking=\nSet the ONONBLOCK flag for all file descriptors passed via socket-based activation. If\ntrue, all file descriptors >= 3 (i.e. all except stdin, stdout, stderr), excluding those\npassed in via the file descriptor storage logic (see FileDescriptorStoreMax= for\ndetails), will have the ONONBLOCK flag set and hence are in non-blocking mode. This\noption is only useful in conjunction with a socket unit, as described in\nsystemd.socket(5) and has no effect on file descriptors which were previously saved in\nthe file-descriptor store for example. Defaults to false.\n\nNotifyAccess=\nControls access to the service status notification socket, as accessible via the\nsdnotify(3) call. Takes one of none (the default), main, exec or all. If none, no daemon\nstatus updates are accepted from the service processes, all status update messages are\nignored. If main, only service updates sent from the main process of the service are\naccepted. If exec, only service updates sent from any of the main or control processes\noriginating from one of the Exec*= commands are accepted. If all, all services updates\nfrom all members of the service's control group are accepted. This option should be set\nto open access to the notification socket when using Type=notify or WatchdogSec= (see\nabove). If those options are used but NotifyAccess= is not configured, it will be\nimplicitly set to main.\n\nNote that sdnotify() notifications may be attributed to units correctly only if either\nthe sending process is still around at the time PID 1 processes the message, or if the\nsending process is explicitly runtime-tracked by the service manager. The latter is the\ncase if the service manager originally forked off the process, i.e. on all processes that\nmatch main or exec. Conversely, if an auxiliary process of the unit sends an sdnotify()\nmessage and immediately exits, the service manager might not be able to properly\nattribute the message to the unit, and thus will ignore it, even if NotifyAccess=all is\nset for it.\n\nHence, to eliminate all race conditions involving lookup of the client's unit and\nattribution of notifications to units correctly, sdnotifybarrier() may be used. This\ncall acts as a synchronization point and ensures all notifications sent before this call\nhave been picked up by the service manager when it returns successfully. Use of\nsdnotifybarrier() is needed for clients which are not invoked by the service manager,\notherwise this synchronization mechanism is unnecessary for attribution of notifications\nto the unit.\n\nSockets=\nSpecifies the name of the socket units this service shall inherit socket file descriptors\nfrom when the service is started. Normally, it should not be necessary to use this\nsetting, as all socket file descriptors whose unit shares the same name as the service\n(subject to the different unit name suffix of course) are passed to the spawned process.\n\nNote that the same socket file descriptors may be passed to multiple processes\nsimultaneously. Also note that a different service may be activated on incoming socket\ntraffic than the one which is ultimately configured to inherit the socket file\ndescriptors. Or, in other words: the Service= setting of .socket units does not have to\nmatch the inverse of the Sockets= setting of the .service it refers to.\n\nThis option may appear more than once, in which case the list of socket units is merged.\nNote that once set, clearing the list of sockets again (for example, by assigning the\nempty string to this option) is not supported.\n\nFileDescriptorStoreMax=\nConfigure how many file descriptors may be stored in the service manager for the service\nusing sdpidnotifywithfds(3)'s \"FDSTORE=1\" messages. This is useful for implementing\nservices that can restart after an explicit request or a crash without losing state. Any\nopen sockets and other file descriptors which should not be closed during the restart may\nbe stored this way. Application state can either be serialized to a file in /run/, or\nbetter, stored in a memfdcreate(2) memory file descriptor. Defaults to 0, i.e. no file\ndescriptors may be stored in the service manager. All file descriptors passed to the\nservice manager from a specific service are passed back to the service's main process on\nthe next service restart (see sdlistenfds(3) for details about the precise protocol\nused and the order in which the file descriptors are passed). Any file descriptors passed\nto the service manager are automatically closed when POLLHUP or POLLERR is seen on them,\nor when the service is fully stopped and no job is queued or being executed for it. If\nthis option is used, NotifyAccess= (see above) should be set to open access to the\nnotification socket provided by systemd. If NotifyAccess= is not set, it will be\nimplicitly set to main.\n\nUSBFunctionDescriptors=\nConfigure the location of a file containing USB FunctionFS[2] descriptors, for\nimplementation of USB gadget functions. This is used only in conjunction with a socket\nunit with ListenUSBFunction= configured. The contents of this file are written to the ep0\nfile after it is opened.\n\nUSBFunctionStrings=\nConfigure the location of a file containing USB FunctionFS strings. Behavior is similar\nto USBFunctionDescriptors= above.\n\nOOMPolicy=\nConfigure the Out-Of-Memory (OOM) killer policy. On Linux, when memory becomes scarce the\nkernel might decide to kill a running process in order to free up memory and reduce\nmemory pressure. This setting takes one of continue, stop or kill. If set to continue and\na process of the service is killed by the kernel's OOM killer this is logged but the\nservice continues running. If set to stop the event is logged but the service is\nterminated cleanly by the service manager. If set to kill and one of the service's\nprocesses is killed by the OOM killer the kernel is instructed to kill all remaining\nprocesses of the service, too. Defaults to the setting DefaultOOMPolicy= in systemd-\nsystem.conf(5) is set to, except for services where Delegate= is turned on, where it\ndefaults to continue.\n\nUse the OOMScoreAdjust= setting to configure whether processes of the unit shall be\nconsidered preferred or less preferred candidates for process termination by the Linux\nOOM killer logic. See systemd.exec(5) for details.\n\nCheck systemd.exec(5) and systemd.kill(5) for more settings.\n",
            "subsections": []
        },
        "COMMAND LINES": {
            "content": "This section describes command line parsing and variable and specifier substitutions for\nExecStart=, ExecStartPre=, ExecStartPost=, ExecReload=, ExecStop=, and ExecStopPost= options.\n\nMultiple command lines may be concatenated in a single directive by separating them with\nsemicolons (these semicolons must be passed as separate words). Lone semicolons may be\nescaped as \"\\;\".\n\nEach command line is unquoted using the rules described in \"Quoting\" section in\nsystemd.syntax(7). The first item becomes the command to execute, and the subsequent items\nthe arguments.\n\nThis syntax is inspired by shell syntax, but only the meta-characters and expansions\ndescribed in the following paragraphs are understood, and the expansion of variables is\ndifferent. Specifically, redirection using \"<\", \"<<\", \">\", and \">>\", pipes using \"|\", running\nprograms in the background using \"&\", and other elements of shell syntax are not supported.\n\nThe command to execute may contain spaces, but control characters are not allowed.\n\nThe command line accepts \"%\" specifiers as described in systemd.unit(5).\n\nBasic environment variable substitution is supported. Use \"${FOO}\" as part of a word, or as a\nword of its own, on the command line, in which case it will be erased and replaced by the\nexact value of the environment variable (if any) including all whitespace it contains, always\nresulting in exactly a single argument. Use \"$FOO\" as a separate word on the command line, in\nwhich case it will be replaced by the value of the environment variable split at whitespace,\nresulting in zero or more arguments. For this type of expansion, quotes are respected when\nsplitting into words, and afterwards removed.\n\nIf the command is not a full (absolute) path, it will be resolved to a full path using a\nfixed search path determined at compilation time. Searched directories include\n/usr/local/bin/, /usr/bin/, /bin/ on systems using split /usr/bin/ and /bin/ directories, and\ntheir sbin/ counterparts on systems using split bin/ and sbin/. It is thus safe to use just\nthe executable name in case of executables located in any of the \"standard\" directories, and\nan absolute path must be used in other cases. Using an absolute path is recommended to avoid\nambiguity. Hint: this search path may be queried using systemd-path search-binaries-default.\n\nExample:\n\nEnvironment=\"ONE=one\" 'TWO=two two'\nExecStart=echo $ONE $TWO ${TWO}\n\nThis will execute /bin/echo with four arguments: \"one\", \"two\", \"two\", and \"two two\".\n\nExample:\n\nEnvironment=ONE='one' \"TWO='two two' too\" THREE=\nExecStart=/bin/echo ${ONE} ${TWO} ${THREE}\nExecStart=/bin/echo $ONE $TWO $THREE\n\nThis results in /bin/echo being called twice, the first time with arguments \"'one'\",\n\"'two two' too\", \"\", and the second time with arguments \"one\", \"two two\", \"too\".\n\nTo pass a literal dollar sign, use \"$$\". Variables whose value is not known at expansion time\nare treated as empty strings. Note that the first argument (i.e. the program to execute) may\nnot be a variable.\n\nVariables to be used in this fashion may be defined through Environment= and\nEnvironmentFile=. In addition, variables listed in the section \"Environment variables in\nspawned processes\" in systemd.exec(5), which are considered \"static configuration\", may be\nused (this includes e.g.  $USER, but not $TERM).\n\nNote that shell command lines are not directly supported. If shell command lines are to be\nused, they need to be passed explicitly to a shell implementation of some kind. Example:\n\nExecStart=sh -c 'dmesg | tac'\n\nExample:\n\nExecStart=echo one ; echo \"two two\"\n\nThis will execute echo two times, each time with one argument: \"one\" and \"two two\",\nrespectively. Because two commands are specified, Type=oneshot must be used.\n\nExample:\n\nExecStart=echo / >/dev/null & \\; \\\nls\n\nThis will execute echo with five arguments: \"/\", \">/dev/null\", \"&\", \";\", and \"ls\".\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "",
            "subsections": [
                {
                    "name": "Example 2. Simple service",
                    "content": "The following unit file creates a service that will execute /usr/sbin/foo-daemon. Since no\nType= is specified, the default Type=simple will be assumed. systemd will assume the unit to\nbe started immediately after the program has begun executing.\n\n[Unit]\nDescription=Foo\n\n[Service]\nExecStart=/usr/sbin/foo-daemon\n\n[Install]\nWantedBy=multi-user.target\n\nNote that systemd assumes here that the process started by systemd will continue running\nuntil the service terminates. If the program daemonizes itself (i.e. forks), please use\nType=forking instead.\n\nSince no ExecStop= was specified, systemd will send SIGTERM to all processes started from\nthis service, and after a timeout also SIGKILL. This behavior can be modified, see\nsystemd.kill(5) for details.\n\nNote that this unit type does not include any type of notification when a service has\ncompleted initialization. For this, you should use other unit types, such as Type=notify if\nthe service understands systemd's notification protocol, Type=forking if the service can\nbackground itself or Type=dbus if the unit acquires a DBus name once initialization is\ncomplete. See below.\n"
                },
                {
                    "name": "Example 3. Oneshot service",
                    "content": "Sometimes, units should just execute an action without keeping active processes, such as a\nfilesystem check or a cleanup action on boot. For this, Type=oneshot exists. Units of this\ntype will wait until the process specified terminates and then fall back to being inactive.\nThe following unit will perform a cleanup action:\n\n[Unit]\nDescription=Cleanup old Foo data\n\n[Service]\nType=oneshot\nExecStart=/usr/sbin/foo-cleanup\n\n[Install]\nWantedBy=multi-user.target\n\nNote that systemd will consider the unit to be in the state \"starting\" until the program has\nterminated, so ordered dependencies will wait for the program to finish before starting\nthemselves. The unit will revert to the \"inactive\" state after the execution is done, never\nreaching the \"active\" state. That means another request to start the unit will perform the\naction again.\n\nType=oneshot are the only service units that may have more than one ExecStart= specified. For\nunits with multiple commands (Type=oneshot), all commands will be run again.\n\nFor Type=oneshot, Restart=always and Restart=on-success are not allowed.\n"
                },
                {
                    "name": "Example 4. Stoppable oneshot service",
                    "content": "Similarly to the oneshot services, there are sometimes units that need to execute a program\nto set up something and then execute another to shut it down, but no process remains active\nwhile they are considered \"started\". Network configuration can sometimes fall into this\ncategory. Another use case is if a oneshot service shall not be executed each time when they\nare pulled in as a dependency, but only the first time.\n\nFor this, systemd knows the setting RemainAfterExit=yes, which causes systemd to consider the\nunit to be active if the start action exited successfully. This directive can be used with\nall types, but is most useful with Type=oneshot and Type=simple. With Type=oneshot, systemd\nwaits until the start action has completed before it considers the unit to be active, so\ndependencies start only after the start action has succeeded. With Type=simple, dependencies\nwill start immediately after the start action has been dispatched. The following unit\nprovides an example for a simple static firewall.\n\n[Unit]\nDescription=Simple firewall\n\n[Service]\nType=oneshot\nRemainAfterExit=yes\nExecStart=/usr/local/sbin/simple-firewall-start\nExecStop=/usr/local/sbin/simple-firewall-stop\n\n[Install]\nWantedBy=multi-user.target\n\nSince the unit is considered to be running after the start action has exited, invoking\nsystemctl start on that unit again will cause no action to be taken.\n"
                },
                {
                    "name": "Example 5. Traditional forking services",
                    "content": "Many traditional daemons/services background (i.e. fork, daemonize) themselves when starting.\nSet Type=forking in the service's unit file to support this mode of operation. systemd will\nconsider the service to be in the process of initialization while the original program is\nstill running. Once it exits successfully and at least a process remains (and\nRemainAfterExit=no), the service is considered started.\n\nOften, a traditional daemon only consists of one process. Therefore, if only one process is\nleft after the original process terminates, systemd will consider that process the main\nprocess of the service. In that case, the $MAINPID variable will be available in ExecReload=,\nExecStop=, etc.\n\nIn case more than one process remains, systemd will be unable to determine the main process,\nso it will not assume there is one. In that case, $MAINPID will not expand to anything.\nHowever, if the process decides to write a traditional PID file, systemd will be able to read\nthe main PID from there. Please set PIDFile= accordingly. Note that the daemon should write\nthat file before finishing with its initialization. Otherwise, systemd might try to read the\nfile before it exists.\n\nThe following example shows a simple daemon that forks and just starts one process in the\nbackground:\n\n[Unit]\nDescription=Some simple daemon\n\n[Service]\nType=forking\nExecStart=/usr/sbin/my-simple-daemon -d\n\n[Install]\nWantedBy=multi-user.target\n\nPlease see systemd.kill(5) for details on how you can influence the way systemd terminates\nthe service.\n"
                },
                {
                    "name": "Example 6. DBus services",
                    "content": "For services that acquire a name on the DBus system bus, use Type=dbus and set BusName=\naccordingly. The service should not fork (daemonize). systemd will consider the service to be\ninitialized once the name has been acquired on the system bus. The following example shows a\ntypical DBus service:\n\n[Unit]\nDescription=Simple DBus service\n\n[Service]\nType=dbus\nBusName=org.example.simple-dbus-service\nExecStart=/usr/sbin/simple-dbus-service\n\n[Install]\nWantedBy=multi-user.target\n\nFor bus-activatable services, do not include a [Install] section in the systemd service file,\nbut use the SystemdService= option in the corresponding DBus service file, for example\n(/usr/share/dbus-1/system-services/org.example.simple-dbus-service.service):\n\n[D-BUS Service]\nName=org.example.simple-dbus-service\nExec=/usr/sbin/simple-dbus-service\nUser=root\nSystemdService=simple-dbus-service.service\n\nPlease see systemd.kill(5) for details on how you can influence the way systemd terminates\nthe service.\n"
                },
                {
                    "name": "Example 7. Services that notify systemd about their initialization",
                    "content": "Type=simple services are really easy to write, but have the major disadvantage of systemd not\nbeing able to tell when initialization of the given service is complete. For this reason,\nsystemd supports a simple notification protocol that allows daemons to make systemd aware\nthat they are done initializing. Use Type=notify for this. A typical service file for such a\ndaemon would look like this:\n\n[Unit]\nDescription=Simple notifying service\n\n[Service]\nType=notify\nExecStart=/usr/sbin/simple-notifying-service\n\n[Install]\nWantedBy=multi-user.target\n\nNote that the daemon has to support systemd's notification protocol, else systemd will think\nthe service has not started yet and kill it after a timeout. For an example of how to update\ndaemons to support this protocol transparently, take a look at sdnotify(3). systemd will\nconsider the unit to be in the 'starting' state until a readiness notification has arrived.\n\nPlease see systemd.kill(5) for details on how you can influence the way systemd terminates\nthe service.\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "systemd(1), systemctl(1), systemd-system.conf(5), systemd.unit(5), systemd.exec(5),\nsystemd.resource-control(5), systemd.kill(5), systemd.directives(7), systemd-run(1)\n",
            "subsections": []
        },
        "NOTES": {
            "content": "1. Incompatibilities with SysV\nhttps://www.freedesktop.org/wiki/Software/systemd/Incompatibilities\n\n2. USB FunctionFS\nhttps://www.kernel.org/doc/Documentation/usb/functionfs.txt\n\n\n\nsystemd 249                                                                       SYSTEMD.SERVICE(5)",
            "subsections": []
        }
    },
    "summary": "systemd.service - Service unit configuration",
    "flags": [],
    "examples": [
        "The following unit file creates a service that will execute /usr/sbin/foo-daemon. Since no",
        "Type= is specified, the default Type=simple will be assumed. systemd will assume the unit to",
        "be started immediately after the program has begun executing.",
        "[Unit]",
        "Description=Foo",
        "[Service]",
        "ExecStart=/usr/sbin/foo-daemon",
        "[Install]",
        "WantedBy=multi-user.target",
        "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",
        "Type=forking instead.",
        "Since no ExecStop= 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",
        "systemd.kill(5) for details.",
        "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 Type=notify if",
        "the service understands systemd's notification protocol, Type=forking if the service can",
        "background itself or Type=dbus if the unit acquires a DBus name once initialization is",
        "complete. See below.",
        "Sometimes, units should just execute an action without keeping active processes, such as a",
        "filesystem check or a cleanup action on boot. For this, Type=oneshot 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:",
        "[Unit]",
        "Description=Cleanup old Foo data",
        "[Service]",
        "Type=oneshot",
        "ExecStart=/usr/sbin/foo-cleanup",
        "[Install]",
        "WantedBy=multi-user.target",
        "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.",
        "Type=oneshot are the only service units that may have more than one ExecStart= specified. For",
        "units with multiple commands (Type=oneshot), all commands will be run again.",
        "For Type=oneshot, Restart=always and Restart=on-success are not allowed.",
        "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.",
        "For this, systemd knows the setting RemainAfterExit=yes, 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 Type=oneshot and Type=simple. With Type=oneshot, 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 Type=simple, dependencies",
        "will start immediately after the start action has been dispatched. The following unit",
        "provides an example for a simple static firewall.",
        "[Unit]",
        "Description=Simple firewall",
        "[Service]",
        "Type=oneshot",
        "RemainAfterExit=yes",
        "ExecStart=/usr/local/sbin/simple-firewall-start",
        "ExecStop=/usr/local/sbin/simple-firewall-stop",
        "[Install]",
        "WantedBy=multi-user.target",
        "Since the unit is considered to be running after the start action has exited, invoking",
        "systemctl start on that unit again will cause no action to be taken.",
        "Many traditional daemons/services background (i.e. fork, daemonize) themselves when starting.",
        "Set Type=forking in the service's 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",
        "RemainAfterExit=no), the service is considered started.",
        "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 $MAINPID variable will be available in ExecReload=,",
        "ExecStop=, etc.",
        "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, $MAINPID 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 PIDFile= 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.",
        "The following example shows a simple daemon that forks and just starts one process in the",
        "background:",
        "[Unit]",
        "Description=Some simple daemon",
        "[Service]",
        "Type=forking",
        "ExecStart=/usr/sbin/my-simple-daemon -d",
        "[Install]",
        "WantedBy=multi-user.target",
        "Please see systemd.kill(5) for details on how you can influence the way systemd terminates",
        "the service.",
        "For services that acquire a name on the DBus system bus, use Type=dbus and set BusName=",
        "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:",
        "[Unit]",
        "Description=Simple DBus service",
        "[Service]",
        "Type=dbus",
        "BusName=org.example.simple-dbus-service",
        "ExecStart=/usr/sbin/simple-dbus-service",
        "[Install]",
        "WantedBy=multi-user.target",
        "For bus-activatable services, do not include a [Install] section in the systemd service file,",
        "but use the SystemdService= option in the corresponding DBus service file, for example",
        "(/usr/share/dbus-1/system-services/org.example.simple-dbus-service.service):",
        "[D-BUS Service]",
        "Name=org.example.simple-dbus-service",
        "Exec=/usr/sbin/simple-dbus-service",
        "User=root",
        "SystemdService=simple-dbus-service.service",
        "Please see systemd.kill(5) for details on how you can influence the way systemd terminates",
        "the service.",
        "Type=simple 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 Type=notify for this. A typical service file for such a",
        "daemon would look like this:",
        "[Unit]",
        "Description=Simple notifying service",
        "[Service]",
        "Type=notify",
        "ExecStart=/usr/sbin/simple-notifying-service",
        "[Install]",
        "WantedBy=multi-user.target",
        "Note that the daemon has to support systemd's 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 sdnotify(3). systemd will",
        "consider the unit to be in the 'starting' state until a readiness notification has arrived.",
        "Please see systemd.kill(5) for details on how you can influence the way systemd terminates",
        "the service."
    ],
    "see_also": [
        {
            "name": "systemd",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/systemd/1/json"
        },
        {
            "name": "systemctl",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/systemctl/1/json"
        },
        {
            "name": "systemd-system.conf",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/systemd-system.conf/5/json"
        },
        {
            "name": "systemd.unit",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/systemd.unit/5/json"
        },
        {
            "name": "systemd.exec",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/systemd.exec/5/json"
        },
        {
            "name": "systemd.resource-control",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/systemd.resource-control/5/json"
        },
        {
            "name": "systemd.kill",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/systemd.kill/5/json"
        },
        {
            "name": "systemd.directives",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/systemd.directives/7/json"
        },
        {
            "name": "systemd-run",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/systemd-run/1/json"
        }
    ]
}