Halfway point between interactive and daemon?

Travis Griggs travisgriggs at gmail.com
Fri Aug 22 15:27:55 EDT 2014


I have a python3 program that performs a long running service on a semi embedded linux device. I've been in the prototyping stage.  I just run it from the command line and use print() statements to let me know the thing is making acceptable process.

At some point, I need to properly daemonize it. Write an init script, find a logging framework/module, batton all the hatches down, so to speak.

I’m curious if there’s a technique one could use to get half way there. Basically, with minimal modifications, I’d like to get it running at startup. So I can put a line like this in rc.local

nohup python3 myMain.py 2>&1 > /var/log/mylog.log &

Then I can “check” on it when I need to with a tail -f /var/log/mylog.log. But then I have the problem of managing the log size. And also I either have to wait for stdout to flush, or insert sys.stdout.flush() after any of my print()’s.

I haven’t done a lot of these daemon processes (and this is my first with python), so I was curious what those with experience do here.


More information about the Python-list mailing list