$check=1;
while($check){

check the time;
set $check to 0 when the time is right to exit

}


but this will make your program little slow because it check time in each
round

send if others have better ideas

----- Original Message -----
From: "david" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, December 01, 2002 9:59 AM
Subject: RE: how do i make a script run for a certain period of time?


> Nyimi Jose wrote:
>
> > I'm writing a script that has to be automatically
> > executed every day at 6:00 AM via 'dollar universe' scheduler software.
> > I want my script to stop itself at 23:00 PM
> > (I think to timeout via alarm function).
> > The script is mainly a while(1) loop and I want my loop
> > to sleep few seconds before going to the next iteration.
> > How can handle this without mixing alarm and sleep ?
> >
>
> you have a few options:
>
> 1. just mix alarm and sleep. Not all sleep functions are implemented using
> alarm. If yours doesn't, you won't have to worry about it.
>
> 2. use the 4 argument version of the select() function with the first
three
> arguments being undef so you can delay any time you want. you can even get
> finer granularity than a second if your system supports it.
>
> 3. Implement your own "sleep" function. Not really recommanded but I have
> seen people doing things like:
>
> #!/usr/bin/perl -w
> use strict;
>
> while(1){
>         delay(3);
>         #-- task
> }
>
> sub delay{
>         my $time = $_[0] * 999999;
>         for(my $i = 0; $i < $time; $i++){}
> }
>
> __END__
>
> which is NOTHING close to the sleep function and it's wasting your
system's
> CPU resource. it merely slows down the program in a bad way!
>
> 4. check perldoc if you haven't do so. I am sure there are other methods
> that works better since this is a fairly command task. There might even be
> a module in CPAN that deals with that.
>
> david
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to