Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

sleeping for a minute

by learn2earn (Acolyte)
on Feb 18, 2010 at 21:01 UTC ( #824029=perlquestion: print w/ replies, xml ) Need Help??
learn2earn has asked for the wisdom of the Perl Monks concerning the following question:

I have a sensor that generates a webpage automatically, I have written a script that pulls the temperature, I would like to have it run continuously but would prefer it wait a minute between checks for both the devices sake as well as to prevent generating undue memory utilization on the script side, how can I keep it from running for a minute or so, I want it to run all the time, just once a minute.

Comment on sleeping for a minute
Re: sleeping for a minute
by ikegami (Pope) on Feb 18, 2010 at 21:05 UTC
Re: sleeping for a minute
by kennethk (Monsignor) on Feb 18, 2010 at 21:05 UTC
Re: sleeping for a minute
by linuxer (Deacon) on Feb 18, 2010 at 21:13 UTC

    And here's a non-perl suggestion:

    If your script runs on a linux or unix-like system, you can create a cronjob, which runs your script every minute.

    In Windows you could set up a scheduled task to do so.

    I'd prefer running the script every minute (by cron or scheduled task) than having it run continuously and sending it regularly to sleep for a minute.

      Why would you prefer that? Just curious...

        1. In case it dies.
        2. In case it has a memory leak.
        3. In case someone kills it purposely or accidentally
        4. So you dont have to install it to run when the system starts up.
        5. Because making a true daemon or windows service that *behaves well* is a minor PITA
        6. To have more fine grained control on when and how often it runs (day of week, day of month, hours, etc)

        bot403 listed the reasons I was thinking of (even a few more).

      Loading perl every 60 seconds seems like a lot of overhead.

      A periodic (but less frequent) watchdog might be the way to go if you wanted extra reliability.

        I see bot403's point, but I think more along these lines, too. I'd rather just idle for a bit instead of have to start from scratch each time.
Re: sleeping for a minute
by zentara (Archbishop) on Feb 19, 2010 at 12:54 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://824029]
Approved by ikegami
Front-paged by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-09-18 22:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (126 votes), past polls