Systemd – creating a custom service

Generally speaking when creating new custom service, best practice dictates that it is saved in the /etc/systemd/system directory (as opposed to the /lib/systemd/system)

My template for systemd service startup script:

[Unit]
Description=My service description
After=sshd.service

[Service]
ExecStart=/full/path/to/command -with "Parameters"

[Install]
WantedBy=multi-user.target

The script is saved as service_name.service under /etc/systemd/system
Once the service unit file is saved it needs to be enabled:

systemctl enable service_name.service
systemctl start service_name
systemctl status service_name

and to double check:

journalctl -xn

to see if there are any errors caused by the new service.

To memorise few useful systemd terms I have created a memrise course:

memrise_systemd

Leave a Reply

Your email address will not be published. Required fields are marked *

six + 19 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.