c4onastick has asked for the wisdom of the Perl Monks concerning the following question:
I've got a Counter-Strike server that I run (all work and no play is no fun at all!) I have a great piece of perl code that parses the logs and fills a database full of stats (very cool. Psychostats by Stormtrooper). Problem is, usually you just set up a cron job to run the script every 10 minutes or so, but I'm not running the server continuously. I'd like to write a little script, daemon really, that'll check and see if the CS server is up periodically and run the stats script if it is.
What's the proper way to write a daemon? Using Proc::Daemon, one can spawn the daemon process, but what about the meat of the program?
I was considering using something like this:Is there a better/cleaner way? Thanks!while(1){ ... #do stuff here sleep 5; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to Write a Proper Daemon
by Old_Gray_Bear (Bishop) on Apr 22, 2007 at 22:20 UTC | |
|
Re: How to Write a Proper Daemon
by shigetsu (Hermit) on Apr 22, 2007 at 22:16 UTC | |
by c4onastick (Friar) on Apr 22, 2007 at 22:23 UTC | |
|
Re: How to Write a Proper Daemon
by Fletch (Bishop) on Apr 22, 2007 at 23:12 UTC |