Sample systemd file for running processes as daemons.
Edit and place this file in /lib/systemd/system/ and then configure some setting for your service to work:
- Set permissions for the unit file:
sudo chmod 644 /lib/systemd/system/myservice.service
- Configure systemd:
sudo systemctl daemon-reload sudo systemctl enable myservice.service
Extra commands for maintaining systemd
sudo systemctl start application.service sudo systemctl start application
sudo systemctl stop application.service
sudo systemctl restart application.service
sudo systemctl reload application.service
sudo systemctl enable application.service
sudo systemctl disable application.service
systemctl status application.service
Code and information taken from the following web sites:
https://www.codementor.io/@ufukafak/how-to-run-a-python-script-in-linux-with-systemd-1nh2x3hi0e https://code.luasoftware.com/tutorials/linux/auto-start-python-script-on-boot-systemd/ https://unix.stackexchange.com/questions/634410/start-python-script-at-startup