= Systemd service = Ref [https://medium.com/codex/setup-a-python-script-as-a-service-through-systemctl-systemd-f0cc55a42267 here] 1. Setup script to run as service called test.py {{{ #!python import time from datetime import datetime while True: with open("timestamp.txt", "a") as f: f.write("The current timestamp is: " + str(datetime.now())) f.close() time.sleep(10) }}} 2. nano /etc/systemd/system/test.service (name of the service which is test in this case) {{{ [Unit] Description=My test service After=multi-user.target [Service] Type=simple Restart=always ExecStart=/usr/bin/python3 /home//test.py [Install] WantedBy=multi-user.target }}} 3. reload systemctl daemon {{{ #!sh sudo systemctl daemon-reload sudo systemctl enable test.service sudo systemctl start test.service sudo systemctl stop test.service sudo systemctl restart test.service sudo systemctl status test.service }}}