Running python files with Systemd.
This service activates a virtual environment, imports database configuration file and runs a python script.
- Change the file paths to match your directory
- Copy example.service to the services folder /etc/systemd/system/
- Enable the service sudo systemctl enable example.service
- Start the service sudo systemctl start example.service
- Check if service is working sudo systemctl status example.service
- View journal log journalctl -u example.service -f
This requires sendmail
- Config the bash script and change permission chmod +x /bin/unit-status-mail.sh
- Move unit-status-mail@service to /etc/systemd/system/
Original code
http://northernlightlabs.se/systemd.status.mail.on.unit.failure
Digital Ocean - systemd essentials