Table of Contents
1 Overview
2 Units
- .service
- A =service unit describes how to manage a service or application on the server. This will include how to start or stop the service, under which circumstances it should be automatically started, and the dependency and ordering information for related software.
- .socket
- A
socket
unit file describes a network or IPC socket, or a FIFO buffer that systemd uses for socket-based activation. These always have an associated.service
file that will be started when activity is seen on the socket that this unit defines. - .device
- A unit that describes a
device
that has been designated as needingsystemd
management by udev or the sysfs filesystem. Not all devices will have.device
files. Some scenarios where.device
units may be necessary are for ordering, mounting, and accessing the devices. - .mount
- This unit defines a mountpoint on the system to be managed by
systemd
. These are named after the mount path, with slashes changed to dashes. Entries within etcfstab can have units created automatically. - .automount
- An
.automount
unit configures a mountpoint that will be automatically mounted. These must be named after the mount point they refer to and must have a matching .mount unit to define the specifics of the mount. - .swap
- This unit describes swap space on the system. The name of these units must reflect the device or file path of the space.
- .target
- A
target
unit is used to provide synchronization points for other units when booting up or changing states. They also can be used to bring the system to a new state. Other units specify their relation to targets to become tied to the target's operations. - .path
- This unit defines a path that can be used for path-based activation. By default, a
.service
unit of the same base name will be started when the path reaches the specified state. This usesinotify
to monitor the path for changes. - .timer
- A
.timer
unit defines a timer that will be managed by systemd, similar to acron
job for delayed or scheduled activation. A matching unit will be started when the timer is reached. - .snapshot
- A
.snapshot
unit is created automatically by the systemctl snapshot command. It allows you to reconstruct the current state of the system after making changes. Snapshots do not survive across sessions and are used to roll back temporary states. - .slice
- A
.slice
unit is associated with Linux Control Group nodes, allowing resources to be restricted or assigned to any processes associated with the slice. The name reflects its hierarchical position within thecgroup
tree. Units are placed in certain slices by default depending on their type. - .scope
- Scope units are created automatically by
systemd
from information received from its bus interfaces. These are used to manage sets of system processes that are created externally.
3 Examples
3.1 Simple service
[Unit] Description=Worker for consuming the Historian.Q and HistorianStats.Q, and storing in Cassandra. After=network-online.target [Service] Type=simple WorkingDirectory=/home/tef/ ExecStart=/usr/bin/mono /home/tef/Release/Storage.exe Restart=on-failure RestartSec=10 [Install] WantedBy=multi-user.target