Writing a simple linux daemon type thing...
Radovan Garabik
spam at melkor.dnp.fmph.uniba.sk
Fri Jun 14 02:50:35 EDT 2002
Jones <jones at jones.jones> wrote:
: Hi everyone,
: I hope this is a simple question for you guys. I'm new to Python and Linux.
: I'm wondering if Python (and this group) can help me.
: I want a program to always be running in the background that, connects to
: PostgreSQL every few seconds, queries a table, and for each record it finds,
: shells out to the system to execute program.
: My research indicates that "nohup" might do the trick? So would it be as
: simple as writing the program in Python and then puting something like
: "nohup python myprog" in the Linux startup sequence (wherever that may be)?
yes
(python myprog &
would be probably better)
: That's my primary goal. Now... assuming I get past that part, I may want to
: take it a few steps further later on. I'd be happy if you guys could take a
: stab at telling me if these are possible and any tips too...
: a) Make it multi-threaded... As I said before, the number of times it
: executes the external program equals the number of records it finds in the
: table. It would be nice if I could execute the program multiple times
: concurrently in a *controlled* manner (depending on my system resources)
: instead of having to wait for each one to be done before starting another
: one.
there is no need for it to be multithreaded. Just use
os.system("program.py &")
and the program will be executed in the background
: b) Make it fail-safe. I would like to figure out how I could re-launch the
: program if it was to crash.
look for daemontools at http://cr.yp.to
--
-----------------------------------------------------------
| Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik |
| __..--^^^--..__ garabik @ fmph . uniba . sk |
-----------------------------------------------------------
Antivirus alert: file .signature infected by signature virus.
Hi! I'm a signature virus! Copy me into your signature file to help me spread!
More information about the Python-list
mailing list