Python as systemctl service

https://www.loggly.com/blog/new-style-daemons-python/

https://github.com/torfsen/python-systemd-tutorial

This is an easy and not enough tested scrip, you may also enable it to start at boot.

Read about systemctl:

https://www.freedesktop.org/software/systemd/man/systemctl.html

So create a file in /lib/systemd/system

touch python_service.service

sudo nano python_service.service

run the script with (when it is done and has no erros):

This is my test script:

It prints service and writes to a file:

sudo systemctl start python_service.service

sudo systemctl status python_service.service

sudo systemctl stop python_service.service

Now lets clean the file and run it as a service:

sudo systemctl start python_service.service

Now lets stop it and check status, and check the file

And the file is full, nice, but the dir is now / (have to check that)

Change python exe to env exe (have to test this):

https://gist.github.com/ricferr/90583f608f0b0ae9c3cf6833be04ab85