I'd like to use my Pi as a home thermostat, with the control loop running in a python script. I want to run it as a daemon on raspbian (debian) at startup.

There's an example bash script in /etc/init.d/skeleton, but it seems unpythonic to mash bash and python together. There are python modules and deb packages that can help with start/stop/alert command processing:

Has anyone had success with a particular approach for daemonizing a "real-time" feedback control loop on the Pi?

2 Answers 2


I have done this on several projects. https://bitbucket.org/dnetman99/raspberrypiprojects if you look at the gpsdpiTracker, the trackerServer.py uses the daemon class to daemonize the script. I then just use restartd to watch if it stops and restarts it, which also means it will start it after boot as well. I also have used the skeleton file for start, stop daemon, but is not necessary if you use this method.

restartd = sudo apt-get install restartd
  • Thanks! Awesome examples. Will see if I can recycle some of that code. The daemon class is from python-daemon module based on PEP 3143 and restartd is here.
    – hobs
    Mar 12, 2013 at 17:56
  • Actually looks like you rolled your own Daemon class. Nice.
    – hobs
    Mar 12, 2013 at 18:05
  • 1
    Except for the she-bang line, the Demon class in dnetman99's bitbucket is identical to Sander Marechal's simple daemon from 2007. Credit where credit is due. Via here
    – RolfBly
    Nov 16, 2014 at 21:38

Look at the way we daemonize in the client pybit-client.


That was designed to run as a daemon on small ARM boxes 24/7.

Handles logging, signal handling, start/stop scripts etc...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.