On Tue, 2004-05-18 at 16:02, [EMAIL PROTECTED] wrote:
> Hi all,
>
> I'm writing a script which fetches data every hour. I thought instead of
> using cron which is platform dependent, to use sleep and a goto statement. Is
> there any downfalls to this?
Yes.
With sleep, once the machine is restarted, your process goes away. With
Cron, everything resumes its normal behaviour (and there are probably
other downfalls).
> At the start of the script I check to see if it was ran in the previous hour.
>
> BEGINNING:
> if(open(TIMECHECK, "./synop_daemon_timer.txt")){
> my($cur_sec1,$cur_min1,$cur_hour1,$cur_day1,$cur_mon1) = <TIMECHECK>;
> my($cur_sec,$cur_min,$cur_hour,$cur_day,$cur_mon,$cur_year)=gmtime(time());
> if($cur_hour1 eq $cur_hour && $cur_day1 eq $cur_day){
> print "<br> SCRIPT IS ALREADY IN ACTION, CANNOT CONTINUE";
> exit(0);
> }
> close(TIMECHECK);
> }
I think this is too much work for something that Cron already does...
are you really going to take your code to a platform without Cron?
> # at the end of the script I write the last time the script was started
> if(open(TIMER, ">./synop_daemon_timer.txt")){
>
> my($cur_sec,$cur_min,$cur_hour,$cur_day,$cur_mon,$cur_year,$junk)=gmtime(time());
> print TIMER "$cur_sec,$cur_min,$cur_hour,$cur_day,$cur_mon\n";
> close(TIMER);
> }
> sleep(360);
> goto(BEGINNING);
>
> Thanks
Take a look at Schedule::Cron
HTH,
jac
--
Josà Alves de Castro <[EMAIL PROTECTED]>
Telbit - Tecnologias de InformaÃÃo
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>