I have a simple clock script in ~/bin/clock/clock.py
. I want to run it as a service. That is, I want it to run in the background as a daemon, and I want it to run automatically at boot. I'll use Supervisor to accomplish this.
$ sudo apt-get install supervisor
$ sudo vim /etc/supervisor/conf.d/clock.conf
In this new configuration file, put the following:
[program:clock]
directory=/home/larz/bin/clock
command=python clock.py
autostart=true
autorestart=true
Now to get the configuration read and get the new service running:
$ sudo supervisorctl update
clock: added process group
$ sudo supervisorctl restart clock
clock: stopped
clock: started
$
Hooray! Clock!