links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Last updated at 10:16 pm UTC on 8 September 2017

Notes on making a program run as a service on Raspbian

As part of the WeatherStation I needed to make the (gack)Python program reading the sensors be a service that would start up after any reboot. Current Raspbian uses systemd, which h seems to be reviled and worshipped in roughly equal measure.

What worked for my purposes was adding a 'unit file' in /lib/systemd/system called 'weather.service' that consisted of
Description=Weather sensor read and publish

ExecStart=/usr/bin/python /home/pi/WeatherPiMQTT/TPR-WeatherBoard-MQTT.py


To start up this service you can use
sudo systemctl start weather.service

To enable it as a full service use
sudo systemctl enable weather.service

If you want more wisdom about systems - go somewhere else!