[Tutor] Python Daemon

Kalle Svensson kalle@gnupung.net
Mon, 12 Mar 2001 00:13:27 +0100


Sez Pedro Diaz Jimenez:
> In order to make a daemon, you've got to fork() and kill the father. Then 
> you have a child in the background

That's not true, at least not with my definition of daemon, basically a
process that is left running.  Just start the process in the background
(with an &, like "python script.py &") and exit the shell.
Perhaps with older shells you'll have to run it through nohup or something,
but I don't know.

<offtopic>
Or put it in you system startup scripts, for example /etc/rc.d/rc.local on
Red Hat 6.2 and the like.  On debian, you'd make a script in /etc/init.d/
and link it in /etc/rcN.d/ where N is between 2 and 5.  This will work nicely
on Red Hat too, except it's /etc/rc.d/{init.d,rcN.d} on older versions than
7.0.  If you have more questions about GNU/Linux startup scripts, you can of
course send them to me privately or to your local LUG mailing list, but I
guess it's a bit offtopic for tutor...
</offtopic>

Anyway, my point is that fork()ing should not be necessary.

Peace,
  Kalle
-- 
Email: kalle@gnupung.net     | You can tune a filesystem, but you
Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD
 [ Not signed due to lossage.  Blame Microsoft Outlook Express. ]