How to make a custom systemd service
Last updated: October 20, 2021
Basic systemd commands:
systemctl status
: Show status of all systemd servicesystemctl daemon-reload
: Reload systemd if units are modifiedsystemctl enable
: to enable a new servicesystemctl start
: to start a new servicesystemctl restart
: to restart a service
Example service file
-
Make new service unit file in
/etc/systemd/system/new-service.service
:[Unit] Description = Sensai background service After = network.target [Service] ExecStart = /usr/bin/python3 /home/lento/projects/sensai/log.py User = lento Group = lento [Install] WantedBy = default.target
-
Reload systemd and enable the service
systemctl daemon-reload systemctl enable new-service.service
-
Start the new service
systemctl start new-service.service
-
Inspect the status
systectl status new-service.service
Last update:
March 9, 2022