How to add a new service to Systemd

%3 cluster_c79e5caa_83bf_46f0_a8f0_f949cf650b10 How to add a new service to Systemd _5a895a21_132a_44e3_8105_1f6f0c094bc2 Systems Administration __0:cluster_c79e5caa_83bf_46f0_a8f0_f949cf650b10->_5a895a21_132a_44e3_8105_1f6f0c094bc2

Say we have a new service gotify-reader that we want to run on systemd. The steps to do so are the following:

[Unit]
Description=Start gotify-reader

[Service]
ExecStart=/usr/bin/start-gotify-reader

[Install]
# WantedBy=
# ^ service/runlevel which needs this

This gives the minimal information that systemd needs to create the service: name (Description), how to operate it (ExecStart) and if it's needed for another one to work (WantedBy).

The exec script can be as simple as calling another script with certain parameters, there's no special control needed for basic services.

Done! Service can be now operated with systemctl.

systemctl start gotify-reader   # Starts service
systemctl restart gotify-reader # Restarts service
systemctl stop gotify-reader    # Stops service

# Enable automatically launching the service if another depends on it
systemclt enable gotify-reader