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?

Other downfalls:

- Cron has automatic e-mail sending (should things go awry)

- With Cron, you know it runs every *exact* hour (OTOH, a script started
at 15:15 would keep running at *:15 plus some incrementing delay)

- service crond start / stop / status are a very good way of keeping
track of cron processes. Should you want to stop your script, you would
have to find its process id and kill it; plus, running it again would
make it run some time later/sooner than expected at first (again, cron
resumes normal behaviour).

- others, certainly


> 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 
-- 
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>


Reply via email to