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
socketunit file describes a network or IPC socket, or a FIFO buffer that systemd uses for socket-based activation. These always have an associated.servicefile that will be started when activity is seen on the socket that this unit defines. - .device
- A unit that describes a
devicethat has been designated as needingsystemdmanagement by udev or the sysfs filesystem. Not all devices will have.devicefiles. Some scenarios where.deviceunits 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
.automountunit 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
targetunit 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
.serviceunit of the same base name will be started when the path reaches the specified state. This usesinotifyto monitor the path for changes. - .timer
- A
.timerunit defines a timer that will be managed by systemd, similar to acronjob for delayed or scheduled activation. A matching unit will be started when the timer is reached. - .snapshot
- A
.snapshotunit 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
.sliceunit 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 thecgrouptree. Units are placed in certain slices by default depending on their type. - .scope
- Scope units are created automatically by
systemdfrom 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