473,769 Members | 5,910 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python program as daemon?

Is it possible to run a Python program as daemon?
Thanks
Jul 25 '08 #1
6 3988
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
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
On Jul 25, 8:37*pm, Johny <pyt...@hope.cz wrote:
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
In message
<13************ *************** *******@x35g200 0hsb.googlegrou ps.com>,
sturlamolden wrote:
Basically it forks twice ...
What's the advantage of forking twice over forking once and calling setsid?
Jul 28 '08 #5
Lawrence D'Oliveiro schrieb:
In message
<13************ *************** *******@x35g200 0hsb.googlegrou ps.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
On 25 Jul, 20:05, sturlamolden <sturlamol...@y ahoo.nowrote:
On Jul 25, 8:37 pm, Johny <pyt...@hope.cz wrote:
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2143
by: Bob Swerdlow | last post by:
I've created a Python daemon that starts a bunch of BitTorrent downloader process. Everything is working fine when I start the daemon by hand (logged on as root). I can quit the session and see that the daemon is running and the subprocesses are running, too. However, when I configure the system to automatically start the daemon on boot-up, the daemon runs, but the processes are not created. This is on Solaris 8 with Python 2.3.3. ...
6
1840
by: Nils Emil P. Larsen | last post by:
Hello I'm building a daemon in Python. It will measure and control some physical devices on a serial bus. Since it is a daemon, it will never terminate and I can't interfere with the regulation of the devices by using command line parameters. I want to control the regulation by using a Internet browser. What is the easiest way to make my threaded Python daemon communicate with a PHP-script running from Apache2 on localhost?
0
1677
by: Jon Monteleone | last post by:
Greetings, I posted a few days back and didnt get much of a response, so I figured I would post again with more detail. I am running gnome under fedora core 4. I want a kid to be able to drop a quarter into a coin slot and get 15 minutes of time on an account that has "restricted" Internet access via the firefox web browser. We are experimenting with different ways to allow kids to safely surf the web during school hours while...
8
11238
by: Bernard Lebel | last post by:
Hello, I would like to know if there is a way to run a Python file under a different user account than the one logged in. Allow me to explain. There are a bunch of people here, they are "basic user", with limited permissions. Basically there are locations on the network where they can only read and execute files, but no way to write. Now, if these users want to write or modify files and directories,
16
3093
by: diffuser78 | last post by:
I want to write a python program and call OS specific commands in it. So basically, instead of typing in on the command line argument I want to have it in a python program and let it do the action. for example. in my program I would want to call the ssh feature like one does on the command line ssh Admin@192.168.2.10 .....etc How can I do this easily ?
3
5213
by: Thomas Dybdahl Ahle | last post by:
Hi, I'm writing a program, using popen4(gnuchess), The problem is, that gnuchess keeps running after program exit. I know about the atexit module, but in java, you could make a process a daemon process, and it would only run as long as the real processes ran. I think this is a better way to stop gnuchess, as you are 100% sure, that it'll stop. Can you do this with popen?
3
4829
by: Mike Orr | last post by:
I'm trying to install a program that uses Durus on a server. It appears that if a Python program uses eggs, it creates a ~/.python-eggs/ directory, so the home directory must be writeable. This conflicts with server environments where you want to run a daemon with minimum privileges. Second, it appears to use the real user ID rather than the effective user ID to choose the home directory. In this case I'm trying to use start-stop-daemon...
10
1713
by: NinjaZombie | last post by:
Hi! I was wondering if it is possible to turn the current python proccess into a unix daemon, but not doing it like this: python myscript.py & but from code programaticaly. Thanks.
2
1141
by: Michael Palmer | last post by:
On Sep 5, 9:56 pm, Sean Davis <seand...@gmail.comwrote: xmlrpc is the right idea, as it interfaces easily across languages.
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10214
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9996
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.