How to Create a Systemd Service in Linux

systemd

Systemd is a modern software suite that provides many components on a Linux system including a system and service manager. It is compatible with SysV and LSB init scripts and works as a replacement for sysvinit.

For easier management, units are categorized into several types: target, service, socket, device, mount, automount, swap, path, timer, snapshot, slice, scope, and busname.

A systemd service is defined in a unit file (a unit is a representation of a service and system resources such as devices, sockets, mount points, etc.). Custom service unit files should be stored in the /etc/systemd/system/ directory and must have an .service extension. For example, a custom test-app service uses /etc/systemd/system/test-app.service unit file.

A unit file is a plain text ini-style file that usually includes three common sections. The first section is usually the Unit section which carries generic information about the unit that is not dependent on the type of unit.

The next section is the unit type section, for a service, it is a Service section. And the final section is the Install section which carries installation information for the unit.

In this guide (linked below), they show how to create a new systemd service and manage the service using the systemctl command, in Linux. It is one of the more concise and easier-to-read guides that I have seen.

See https://www.tecmint.com/create-systemd-service-linux/