SYSTEMD.SERVICE(5) systemd.service SYSTEMD.SERVICE(5) (NAME) systemd.service - systemd (SYNOPSIS) service.service (DESCRIPTION) ".service" systemd . . systemd.unit(5) . [Unit] [Install] . [Service] . systemd.exec(5) systemd.kill(5) systemd.resource- control(5) . SysV init systemd SysV init ( ".service") systemd-sysv-generator(8) . systemd-run(1) .service .scope . (SERVICE TEMPLATES) systemd "service@argument.service" . <<>> (instantiated) argument <<>> (template) . dhcpcd@.service . << >> %- . systemd.unit(5) . (AUTOMATIC DEPENDENCIES) (Implicit Dependencies) : o Type=dbus Requires= After= dbus.socket . o .socket After= . .socket Sockets= Wants= After= . systemd.exec(5) systemd.resource-control(5) . (Default Dependencies) DefaultDependencies=no : o Requires= After= sysinit.target After= basic.target Conflicts= Before= shutdown.target . . . o ( "@" ) (slice unit) ( systemd.slice(5)) . . DefaultDependencies=no DefaultDependencies=no Slice=system.slice ( ) . systemd.resource-control(5) . (OPTIONS) [Unit] [Install] systemd.unit(5) . [Service] . . systemd.exec(5) systemd.kill(5) systemd.resource-control(5) . [Service] : Type= . simple exec forking oneshot dbus notify notify-reload idle: o simple ( ExecStart= Type= BusName= ) (fork) ( fork() execve() ) . Type=exec . ExecStart= . ( systemd ) . systemctl start simple ( User= ). o exec simple . . ( : simple fork() exec fork() execve() .) systemctl start exec ( User= ) . (credentials) ( LoadCredential= systemd.exec(5) ). o forking . notify notify-reload dbus . ExecStart= fork() . . . UNIX . PIDFile= systemd . . o oneshot exec . . RemainAfterExit= . Type=oneshot Type= ExecStart= . RemainAfterExit= "active" "activating" "deactivating" "dead" . ( RemainAfterExit= ) (dead) . o dbus simple BusName= . BusName= . dbus.socket . (activating) . (activated) . . SIGTERM ( KillSignal= ) . o notify exec "READY=1" sd_notify(3) . systemd . NotifyAccess= ( ) systemd . NotifyAccess= none main . (reloading) notify-reload . o notify-reload notify : SIGHUP . sd_notify(3) "RELOADING=1" "MONOTONIC_USEC=" ( CLOCK_MONOTONIC clock_gettime(2)) . "READY=1" . ExecReload= . ReloadSignal= . o idle simple . . . Type=exec ( ) . ( execve() ) ( IPC IPC -- ) . notify notify-reload dbus ( D-Bus ) . notify/notify-reload ( sd_notify() API ) -- forking : UNIX . simple . ( idle oneshot .) ( User= Group= libc NSS) IPC <<>> . simple . ExitType= . main cgroup: o main ( ) ( Type= ) . Type=oneshot . o cgroup cgroup . (forking) ExitType=main . ExitType=cgroup . . 250 . RemainAfterExit= . no . GuessMainPID= systemd PID . Type=forking PIDFile= PID PID . . PID . yes . PIDFile= PID . Type= forking . /run/ . /run/ $XDG_RUNTIME_DIR . PID . . PID : ( ) PID . PID . Type=notify Type=notify-reload Type=simple PID . BusName= D-Bus . Type= dbus . D-Bus . systemctl service-log-level/service-log-target . ExecStart= . Type= oneshot . Type=oneshot . . ExecStart= RemainAfterExit=yes ExecStop= . ( ExecStart= ExecStop= .) . ( "-" ) . Type=forking . ExecStartPre=, ExecStartPost= ExecStart= . ExecStart= . ( Type=) . ( "-" ) . ExecStart= ExecStartPre= "-" . ExecStartPost= ExecStart= Type= ( Type=simple Type=idle ExecStart= Type=oneshot Type=forking "READY=1" Type=notify/Type=notify-reload BusName= Type=dbus ). ExecStartPre= . ExecStartPre= . ExecStartPre= ExecStart= ExecStartPost= ( "-" ) ExecStopPost= ExecStop= . ExecStartPost= Before=/After= . ExecCondition= ExecStartPre= . ExecStart= . ( Type=) . ExecStartPre= : ExecCondition= ( ) . ExecCondition= ( ) ( ). SuccessExitStatus= . ExecStartPre= ExecCondition= . ExecCondition= ExecStopPost= . 243 . ExecReload= . ExecStart= . . ExecStart= . : $MAINPID : ExecReload=kill -HUP $MAINPID ( ) . Type=notify-reload ExecReload= ExecReload= . dbus-broker?R(1) : ExecReload=busctl call org.freedesktop.DBus \ /org/freedesktop/DBus org.freedesktop.DBus \ ReloadConfig ExecStop= ExecStart=. ExecStart= . . KillMode= ( systemd.kill(5) ). KillSignal= RestartKillSignal= . ( $MAINPID ). ( ) . KillMode= KillSignal= RestartKillSignal= . . ExecStop= . ( ExecStart= ExecStartPre= ExecStartPost= [ "-" ] ) . ExecStopPost= . . . systemd $MAINPID . . ExecStop= ExecStopPost= . . ExecStopPost= . ExecStopPost= . ExecStop= ExecStop= . ExecStart= . . . -- ExecStop= -- . . . . $SERVICE_RESULT $EXIT_CODE $EXIT_STATUS systemd.exec(5) . ExecStopPost= Before=/After= . RestartSec= ( Restart= ) . "5min 20s" . 100ms . RestartSteps= RestartSec= RestartMaxDelaySec= . 0 . 0 . :?R (exponential backoff) . : RestartSec=10s RestartSteps=4 RestartMaxDelaySec=160s : 10s 20s 40s 80s 160s 160s 160s . . ratio (RestartMaxDelaySec / RestartSec)^(1 / RestartSteps). () RestartMaxDelaySec= RestartSteps + 1 . RestartMaxDelaySec= RestartSec= . 254 . RestartMaxDelaySec= RestartSteps= . RestartSec= "infinity" . "infinity" . RestartSteps= RestartSec= . 254 . TimeoutStartSec= . . TimeoutStartFailureMode= . "5min 20s" . "infinity" . DefaultTimeoutStartSec= Type=oneshot ( systemd-system.conf(5) ). Type=notify/Type=notify-reload "EXTEND_TIMEOUT_USEC=..." TimeoutStartSec= . TimeoutStartSec= TimeoutStartSec= "EXTEND_TIMEOUT_USEC=..." "READY=1" ( sd_notify(3)). ExecReload= Type=notify-reload. . systemctl reload . 188 . TimeoutStopSec= . ExecStop= . ExecStop= SIGTERM . ExecStop= SIGTERM . TimeoutStopFailureMode= . . SIGKILL ( KillMode= systemd.kill(5) ). "5min 20s" . "infinity" . DefaultTimeoutStopSec= ( systemd-system.conf(5) ). Type=notify/Type=notify-reload "EXTEND_TIMEOUT_USEC=..." TimeoutStopSec= . TimeoutStopSec= TimeoutStopSec= "EXTEND_TIMEOUT_USEC=..." ( sd_notify(3)). 188 . TimeoutAbortSec= (watchdog timeout) ( WatchdogSec= ). TimeoutStopSec= (core dump) . SIGKILL ( KillMode= systemd.kill(5) ). (truncated) . TimeoutAbortSec= . "5min 20s" . TimeoutStopSec= . "infinity" . DefaultTimeoutAbortSec= ( systemd- system.conf(5) ). Type=notify/Type=notify-reload SIGABRT ( ) "EXTEND_TIMEOUT_USEC=..." TimeoutAbortSec= . TimeoutAbortSec= TimeoutAbortSec= "EXTEND_TIMEOUT_USEC=..." ( sd_notify(3)). 243 . TimeoutSec= TimeoutStartSec= TimeoutStopSec= . TimeoutStartFailureMode=, TimeoutStopFailureMode= TimeoutStartSec= TimeoutStopSec= . terminate abort kill . terminate . terminate KillSignal= ( SIGTERM systemd.kill(5) ). FinalKillSignal= TimeoutStopSec= . abort WatchdogSignal= TimeoutAbortSec= FinalKillSignal= . . kill FinalKillSignal= . . 246 . RuntimeMaxSec= . . Type=oneshot ( TimeoutStartSec= ). "infinity" () . Type=notify/Type=notify-reload "EXTEND_TIMEOUT_USEC=..." RuntimeMaxSec= . RuntimeMaxSec= RuntimeMaxSec= "EXTEND_TIMEOUT_USEC=..." "STOPPING=1" ( ) ( sd_notify(3)). 229 . RuntimeRandomizedExtraSec= RuntimeMaxSec= 0 ( ) . RuntimeMaxSec= . 250 . WatchdogSec= (watchdog timeout) . . sd_notify(3) "WATCHDOG=1" ( << >>) . SIGABRT ( WatchdogSignal=) . Restart= on-failure on-watchdog on-abnormal always . WATCHDOG_USEC= . . NotifyAccess= ( ) systemd . NotifyAccess= main . 0 . . sd_watchdog_enabled(3) . sd_event_set_watchdog(3) . Restart= . ExecStartPre= ExecStartPost= ExecStop= ExecStopPost= ExecReload= . systemd ( ) . << >> . no on-success on-failure on-abnormal on-watchdog on-abort always . no () . on-success . : o 0 o Type=oneshot SIGHUP SIGINT SIGTERM SIGPIPE o SuccessExitStatus=. on-failure ( ) ( ) . on-abnormal ( ) . on-abort . on-watchdog . always . Type=oneshot always on-success . . Restart= +-------------------------+----+--------+------------+------------+-------------+----------+-------------+ | | no | always | on-success | on-failure | on-abnormal | on-abort | on-watchdog | |Restart/ | | | | | | | | | | | | | | | | | +-------------------------+----+--------+------------+------------+-------------+----------+-------------+ | | | X | X | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-------------------------+----+--------+------------+------------+-------------+----------+-------------+ | | | X | | X | | | | | | | | | | | | | +-------------------------+----+--------+------------+------------+-------------+----------+-------------+ | | | X | | X | X | X | | | | | | | | | | | +-------------------------+----+--------+------------+------------+-------------+----------+-------------+ | | | X | | X | X | | | | | | | | | | | | | | | | | | | | | |(Timeout) | | | | | | | | +-------------------------+----+--------+------------+------------+-------------+----------+-------------+ | | | X | | X | X | | X | |(Watchdog) | | | | | | | | +-------------------------+----+--------+------------+------------+-------------+----------+-------------+ RestartPreventExitStatus= ( ) systemctl stop . RestartForceExitStatus= ( ) . StartLimitIntervalSec= StartLimitBurst= systemd.unit(5) . on-failure . ( ) on-abnormal . RestartMode= : o normal () / (failed/inactive) . 254 . o direct (activating) / . ExecStopPost= . OnSuccess= OnFailure= . . . 254 . o debug (debug level) $DEBUG_INVOCATION=1 . systemd . normal . 257 . 254 . SuccessExitStatus= 0 ( Type=oneshot) SIGHUP SIGINT SIGTERM SIGPIPE . . systemd.exec(5) ( "EXIT_" "EX_" ). signal(7) . 0 "SUCCESS" ( "0/SUCCESS" ) 1 "FAILURE" ( "1/FAILURE" ) . . . . . SuccessExitStatus= SuccessExitStatus=TEMPFAIL 250 SIGKILL 75 (TEMPFAIL) 250 SIGKILL . : systemd-analyze exit-status . 189 . RestartPreventExitStatus= Restart= . . . . RestartPreventExitStatus= RestartPreventExitStatus=TEMPFAIL 250 SIGKILL 75 (TEMPFAIL) 250 SIGKILL . . . ExecStartPre= ExecStartPost= ExecStop= ExecStopPost= ExecReload= ExecStart= ( Type= PIDFile= ) . 189 . RestartForceExitStatus= Restart= . RestartPreventExitStatus= . Type=oneshot . 215 . RootDirectoryStartOnly= . (true) RootDirectory= ( systemd.exec(5) ) ExecStart= ExecStartPre= ExecStartPost= ExecReload= ExecStop= ExecStopPost=. (false) . . NonBlocking= O_NONBLOCK . (true) >= 3 ( stdin stdout stderr) ( FileDescriptorStoreMax= ) O_NONBLOCK (non-blocking) . systemd.socket(5) . (false) . ( Sockets= ) NonBlocking= O_NONBLOCK O_NONBLOCK . NonBlocking= . NotifyAccess= sd_notify(3) . none () main exec all . none . main . exec Exec*= . all (control group) . Type=notify/Type=notify-reload WatchdogSec= ( ). NotifyAccess= main . sd_notify() PID 1 . main exec . sd_notify() NotifyAccess=all . (race conditions) sd_notify_barrier() . . sd_notify_barrier() . Sockets= . ( ) . . . : Service= .socket Sockets= .service . . ( ) . FileDescriptorStoreMax= "FDSTORE=1" sd_pid_notify_with_fds(3) . (crash) . . RuntimeDirectory= memfd_create(2) . 0 . ( sd_listen_fds(3) ). POLLHUP POLLERR ( FileDescriptorStorePreserve= ). NotifyAccess= ( ) systemd . NotifyAccess= main . fdstore systemd-analyze(1) . IPC . . ( ) . $FDSTORE . systemd.exec(5) . File Descriptor Store[1] . 219 . FileDescriptorStorePreserve= no yes restart ( ) . no restart () . yes ( ) . . systemctl clean --what=fdstore ... . 254 . USBFunctionDescriptors= USB FunctionFS[2] USB . ListenUSBFunction= . ep0 . 227 . USBFunctionStrings= USB FunctionFS . USBFunctionDescriptors= . 227 . OOMPolicy= (OOM) OOM systemd-oomd.service(8) . . systemd-oomd.service . continue stop kill . continue OOM . stop . kill OOM memory.oom.group 1 Control Group v2[3] . DefaultOOMPolicy= systemd-system.conf(5) Delegate= continue . OOMScoreAdjust= OOM . systemd.exec(5) . systemd- oomd.service(8) . OOM systemd-oomd cgroup . 243 . OpenFile= "path[:fd-name:options]" : o "path" AF_UNIX o "fd-name" (ASCII) ":" o "options" "read-only" "append" "truncate" "graceful" rw "graceful" / . . . connect() . sd_listen_fds(3) . / ( ). . . 253 . ReloadSignal= . SIGHUP . Type=notify-reload . 253 . systemd.unit(5) systemd.exec(5) systemd.kill(5) . (COMMAND LINES) ExecStart= ExecStartPre= ExecStartPost= ExecReload= ExecStop= ExecStopPost= ExecCondition= . . "Quoting" systemd.syntax(7) . . . "<" "<<" ">" ">>" (pipes) "|" "&" . . : . +-------------------+--------------------------------------+ | | | +-------------------+--------------------------------------+ |"@" | | | | "@" | | | | | | | | | | | | | | | argv[0] | | | | | | | | | | | | ( | | | ) | | | | | | | | | | | | | | | . | +-------------------+--------------------------------------+ |"-" | | | | "-" | | | | | | | | | | | | | | | | | | ( | | | | | | | | | | | | | | | ) | | | | | | | | | | | | | | | . | +-------------------+--------------------------------------+ |":" | | | | ":" | | | | | | | | | | | | | | | ( | | | | | | | | | ) | | | . | +-------------------+--------------------------------------+ |"+" | | | | "+" | | | | | | | | | | | | | | | . | | | | | | | | | | | | | | | User= Group= | | | CapabilityBoundingSet= | | | | | | | | | | | | | | | ( PrivateDevices= | | | PrivateTmp=) | | | | | | | | | | | | ( | | | | | | ExecStart= | | | ExecStop= | | | ). | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DevicePolicy= | | | | | | | | | systemd.resource-control(5) | | | . | +-------------------+--------------------------------------+ |"!" | | | | "+" | | | | | | | | | | | | | | | | | | | | | | | | . | | | | | | "+" | | | "!" | | | | | | User= Group= | | | SupplementaryGroups= | | | | | | | | | | | | | | | | | | | | | | | | . | | | | | | | | | | | | DynamicUser= | | | | | | | | | | | | / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | . | +-------------------+--------------------------------------+ |"!!" | | | | | | | "!" | | | | | | | | | | | | | | | | | | | | | | | | (ambient process | | | capabilities) | | | | | | | | | AmbientCapabilities=. | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | . | | | | | | "!!" | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SystemCallFilter= | | | CapabilityBoundingSet= | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | . | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AmbientCapabilities= | | | | | | | | | . | | | | | | | | | | | | | | | | | | "!!" | | | | | | | | | . | +-------------------+--------------------------------------+ "@" "-" ":" "+"/"!"/"!!" . "+" "!" "!!" . . () . /usr/local/bin/ /usr/bin/ sbin/ ( bin/ sbin/ ). "" . : systemd-path search-binaries-default . "%" systemd.unit(5) . ";" (escape ) "\;" . . "${FOO}" ( ) . "$FOO" . . : Environment="ONE=one" 'TWO=two two' ExecStart=echo $ONE $TWO ${TWO} /bin/echo : "one" "two" "two" "two two". : Environment=ONE='one' "TWO='two &two' &too" THREE= ExecStart=/bin/echo ${ONE} ${TWO} ${THREE} ExecStart=/bin/echo $ONE $TWO $THREE /bin/echo "'one'" "'two &two' &too" "" "one" "two &two" "too". ":" "$$" . . ( ) . Environment= EnvironmentFile= . " " systemd.exec(5) " " ( $USER $TERM). . . : ExecStart=sh -c 'dmesg | tac' : ExecStart=echo one ExecStart=echo "two two" echo : "one" "two two". Type=oneshot . : Type=oneshot ExecStart=:echo $USER ExecStart=-false ExecStart=+:@true $TEST /usr/bin/echo "$USER" (":" ) /usr/bin/false ( "-" ) /usr/bin/true ( "$TEST" argv[0]) . : ExecStart=echo / >/dev/null & \; \ ls echo : "/" ">/dev/null" "&" ";" "ls". (EXAMPLES) . (Simple) /usr/sbin/foo-daemon . Type= Type=simple . systemd . [Unit] Description=Foo [Service] ExecStart=/usr/sbin/foo-daemon [Install] WantedBy=multi-user.target systemd systemd . ( fork ) Type=forking . ExecStop= systemd SIGTERM SIGKILL . systemd.kill(5) . . Type=notify/Type=notify-reload systemd Type=forking Type=dbus DBus . . . (Oneshot) . Type=oneshot . . : [Unit] Description=Cleanup old Foo data [Service] Type=oneshot ExecStart=/usr/sbin/foo-cleanup [Install] WantedBy=multi-user.target systemd "starting" . "inactive" "active" . . Type=oneshot ExecStart= . (Type=oneshot) . Type=oneshot Restart=always Restart=on-success . . oneshot "" . . oneshot . systemd RemainAfterExit=yes systemd . Type=oneshot Type=simple . Type=oneshot systemd . Type=simple . . [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 systemctl start . . Forking / ( fork daemonize ). Type=forking . systemd . ( RemainAfterExit=no) . . systemd . $MAINPID ExecReload= ExecStop= . systemd . $MAINPID . PID systemd PID . PIDFile= . . systemd . : [Unit] Description=My Simple Daemon [Service] Type=forking ExecStart=/usr/sbin/my-simple-daemon -d [Install] WantedBy=multi-user.target systemd systemd.kill(5) . . DBus DBus Type=dbus BusName= . fork (daemonize) . systemd . DBus : [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 bus-activatable [Install] systemd SystemdService= DBus (/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 systemd systemd.kill(5) . . systemd Type=simple systemd . systemd systemd . Type=notify Type=notify-reload . : [Unit] Description=Simple Notifying Service [Service] Type=notify-reload ExecStart=/usr/sbin/simple-notifying-service [Install] WantedBy=multi-user.target systemd systemd . sd_notify(3) . systemd 'starting' . systemd systemd.kill(5) . sd_notify(3) API libsystemd(3) Promise [4] . sd_notify(3) . (SEE ALSO) systemd(1), systemctl(1), systemd-system.conf(5), systemd.unit(5), systemd.exec(5), systemd.resource-control(5), systemd.kill(5), systemd.directives(7), systemd-run(1) (NOTES) 1. File Descriptor Store https://systemd.io/FILE_DESCRIPTOR_STORE 2. USB FunctionFS https://docs.kernel.org/usb/functionfs.html 3. Control Group v2 https://docs.kernel.org/admin-guide/cgroup-v2.html 4. Interface Portability and Stability Promise https://systemd.io/PORTABILITY_AND_STABILITY systemd 257.13 SYSTEMD.SERVICE(5)