LPM: Using sleep()

Rich Bowen rbowen at rcbowen.com
Tue Dec 14 12:38:18 CST 1999


Gregg Casillo wrote:
> 
> I have a script I want to run every 30 minutes or so. On a *nix box, I'd
> add a line to my crontab to do this. No problem, except I'm working with
> an NT box. From my limited knowledge of NT, there is no equivalent of
> cron native to NT. To make a long story shorter, I tried Wincron and
> another DOS cron utility with no success.
> 
> Is there anything wrong with doing the following:
> 
> while (sleep 1800) {
>   ...
>   yaddy-yaddy-yaddah
>   ...
> }
> 
> Does the sleep() routine have a lot of overhead or use a lot of CPU
> cycles? Any better ideas?

sleep() appears to have very low CPU overhead.

However, if you want a real solution, try crond from AINTX
(http://maxx.mc.net/~jlh/nttools.htm) It's a real cron daemon, with a
real crontab file. I think that it will be more what you are used to,
and you don't have to mess with restarting the program if it gets
interrupted, and other annoyances of while(1) programs.

Rich
-- 
http://www.ApacheUnleashed.com/
Lexington Perl Mongers - http://lexington.pm.org/
PGP Key - http://www.rcbowen.com/pgp.txt



More information about the Lexington-pm mailing list