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?
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);
}

# 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 

Reply via email to