Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Waking threads that do periodic checks

by ikegami (Pope)
on Sep 25, 2011 at 05:21 UTC ( #927708=note: print w/ replies, xml ) Need Help??


in reply to Waking threads that do periodic checks

Wouldn't it be simpler to use cron to run your program every hour?


Signals will interrupt sleep if you have a signal handler for them.

my $exit; local $SIG{INT} = local $SIG{TERM} = sub { $exit = 1; }; my $wakeup_time = time + 60*60; for (;;) { if ($exit) { ... exit(0); } my $sleep_dur = $wakeup_time - time; last if $sleep_dur <= 0; sleep($sleep_dur); }


Comment on Re: Waking threads that do periodic checks
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://927708]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (18)
As of 2014-09-22 14:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (195 votes), past polls