Petter Holt Juliussen • Mail | Mastodon | GitHub | Letterboxd

for later reference.

systemd

2019-04-04

systemd is a system and service manager for Linux. It is the default init system for Debian since DebianJessie. Systemd is compatible with SysV and LSB init scripts. It can work as a drop-in replacement for sysvinit.

/etc/systemd/system/my-service.service

[Unit]
Description=My Script Service
After=multi-user.target

[Service]
Type=idle
User=pi
WorkingDirectory=/home/pi
ExecStart=/usr/bin/python /home/pi/myscript.py

[Install]
WantedBy=multi-user.target
sudo chmod 644 /etc/systemd/system/my-script.service

sudo systemctl daemon-reload
sudo systemctl enable my-serive.service

sudo systemctl status my-serive.service