systemd - service


The basic and introductory information about systemd is contained on the manual page systemd-start. The sections [Unit] and [Install] concerning all unit files are covered by our manual page systemd unit file.
On this manual page we explain the function of the unit systemd.service. The unit file with the “.service” name extension is the most commonly encountered unit type in systemd.

The service unit file must contain a [Service] section that configures information about the service and the process it is monitoring.

Create service unit

We prefer to place self-created unit files in the /usr/local/lib/systemd/system/ directory. (If necessary, create the directory with the command mkdir -p /usr/local/lib/systemd/system/.) This has the advantage of giving them priority over system units installed by the distribution’s package manager, while placing control links and change files created with systemctl edit <UNIT_FILE> in the directory /etc/systemd/system/, which itself has a higher priority. See: Hirarchy of load paths.

Service section

There are over thirty options available for this section, of which we describe particularly frequently used ones here.

Type=             PIDFile=
RemainAfterExit=  GuessMainPID=
ExecStart=        Restart=
ExecStartPre=     RestartSec=
ExecStartPost=    SuccessExitStatus=
ExecCondition=    RestartPreventExitStatus=
ExecReload=       RestartForceExitStatus=
ExecStop=         NonBlocking=
ExecStopPost=     NotifyAccess=
TimeoutStopSec=   RootDirectoryStartOnly=
TimeoutStartSec=  FileDescriptorStoreMax=
TimeoutAbortSec=  USBFunctionDescriptors=
TimeoutSec=       USBFunctionStrings=
RuntimeMaxSec=    Sockets=
WatchdogSec=      BusName=

Some self created service units can be found on our manual pages

service-unit for systemd timer,
service-unit for systemd Path,
and with the preferred search engine on the Internet.

Sources systemd-service

man systemd.service

LinuxCommunity, Create systemd units yourself

Last edited: 2022/04/08