Writing a simple linux daemon type thing...

Graham Ashton gashton at cmedltd.com
Mon Jun 17 06:09:08 EDT 2002

On Fri, 2002-06-14 at 14:05, Michael Hudson wrote:

> If you run it as a true daemon, you need to be careful about writing
> to stdout/stderr (because they're not there any more).  Think
> tracebacks.

There's an example of how to do this (which I think I took from Python
Standard Library) in the Daemon class in gmalib. It use's gmalib's
Logger class to send all output to either a normal file, or syslog.

You can download gmalib here:


or save yourself the trouble by browsing the CVS archive first:


It's GPL'd, so feel free to re-use, etc.

Example usage:

  import gmalib

  class MyApp(gmalib.Daemon):
      def __init__(self):
          gmalib.Daemon.__init__(self, logfile="log.txt", use_syslog=0)

Graham Ashton

More information about the Python-list mailing list