By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,735 Members | 1,349 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,735 IT Pros & Developers. It's quick & easy.

Python program as daemon?

P: n/a
Is it possible to run a Python program as daemon?
Thanks
Jul 25 '08 #1
Share this Question
Share on Google+
6 Replies

P: n/a
Johny <py****@hope.cz>:
Is it possible to run a Python program as daemon?
You can write daemons in basically any language out there.

--
Freedom is always the freedom of dissenters.
(Rosa Luxemburg)
Jul 25 '08 #2

P: n/a
Johny wrote:
Is it possible to run a Python program as daemon?
Sure -- see http://code.activestate.com/recipes/66012/ for an example
(and some useful stuff in the comments.)
Jul 25 '08 #3

P: n/a
On Jul 25, 8:37*pm, Johny <pyt...@hope.czwrote:
Is it possible to run a Python program as daemon?
Thanks
Here is an example on how to run a Python script as a Unix daemon:

http://svn.plone.org/svn/collective/...emon/daemon.py

Basically it forks twice and redirects open file descriptors to /dev/
null.

On Windows, 'daemons' are called services. You can write Windows
services in Python using the Pywin32 extension. See Mark Hammond's
book for an explanation.

Jul 25 '08 #4

P: n/a
In message
<13**********************************@x35g2000hsb. googlegroups.com>,
sturlamolden wrote:
Basically it forks twice ...
What's the advantage of forking twice over forking once and calling setsid?
Jul 28 '08 #5

P: n/a
Lawrence D'Oliveiro schrieb:
In message
<13**********************************@x35g2000hsb. googlegroups.com>,
sturlamolden wrote:
>Basically it forks twice ...

What's the advantage of forking twice over forking once and calling setsid?
http://code.activestate.com/recipes/278731/

See the comments.

Diez
Jul 28 '08 #6

P: n/a
On 25 Jul, 20:05, sturlamolden <sturlamol...@yahoo.nowrote:
On Jul 25, 8:37 pm, Johny <pyt...@hope.czwrote:
Is it possible to run a Python program as daemon?
Thanks

Here is an example on how to run a Python script as a Unix daemon:

http://svn.plone.org/svn/collective/...a/daemon/daemo...

Basically it forks twice and redirects open file descriptors to /dev/
null.

On Windows, 'daemons' are called services. You can write Windows
services in Python using the Pywin32 extension. See Mark Hammond's
book for an explanation.
Also, on Windows, you can get good results using srvany

http://support.microsoft.com/kb/137890

I've set this up to run Pyhton for a couple of scripts.

Jul 28 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.