Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Perl Cron Daemon

by perlAffen (Sexton)
on Jun 02, 2011 at 14:32 UTC ( #907802=perlquestion: print w/replies, xml ) Need Help??
perlAffen has asked for the wisdom of the Perl Monks concerning the following question:

I work at a big company, the SAs are like the pigs on Angry Birds where root permission are the eggs they hoard. They won't help the user. Anyway due to some unsolvable auth issues, cron for a particular user stops working every week on a solaris box. The ramifications are huge when this happens. So I was wondering if there was a perl scheduler or something that I could run as daemon that would yield a cron scheduling equivalent. I saw Schedule-Cron but it says it is for executing perl subroutines, when I am forking mostly bash scripts. I was thinking of using a while loop and sleeping, but there is no guarantee that sleeping 60 will always be 60. If I could come up with something that wakes up at :00 seconds every time, I could write the rest. Thanks

Replies are listed 'Best First'.
Re: Perl Cron Daemon
by zek152 (Pilgrim) on Jun 02, 2011 at 14:58 UTC

    The code below will print "Event @ $sec" if the time is either :00 or :01. I don't know how taxing it is on the computer. I think that sleep does an alarm + pause call so it shouldn't be spin waiting. The reason for the sleep(30); is so that there is an additional time to correct for error due to sleep(.).

    while(1) { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime( +); if($sec > 1) { sleep(60-$sec); } else { print "Event @ $sec\n"; sleep(30); } }
      Thanks, it doesn't seem to be any burden to the box. I shall use it.
Re: Perl Cron Daemon
by Bloodnok (Vicar) on Jun 02, 2011 at 14:41 UTC
    So why not have the perl subroutines call the bash scripts via either backticks, qx// or the system call (perlfunc) ?

    A user level that continues to overstate my experience :-))

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://907802]
Approved by Old_Gray_Bear
Front-paged by kcott
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2018-02-20 04:34 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (267 votes). Check out past polls.