SPUG: Sleep

Bill Warner billw at onedrous.org
Wed Jul 20 22:51:45 PDT 2005


Without knowing your requirements, I'll chime in with this. Usually,
when I want to sleep, I want to execute then sleep for an indefinite
number of iterations. Also, I want to execute every 5 minutes, not every
5 minutes plus the exection time. So I end up with something like this.

        my $period = 5*60; # 5 minutes
        while(1) {
         my $btime = time();
         execute();
         my $exec_time = (time() - $btime) % $period; # take the
        remainder just in case execution time exceeds our period
         sleep($period - $exec_time);
        }
        
 -Bill

On Wed, 2005-07-20 at 14:52 -0700, Tim Maher wrote:
> On Wed, Jul 20, 2005 at 03:35:09PM -0600, Medrano-Zaldivar, L E wrote:
> > List,
> > 
> > I need to put sleep a script for 5 min and after that I need
> > for the script to keep running how can I do that?
> 
> > 
> > Thanks,
> > 
> > Luis
> 
> # Ready to sleep for 5 minutes
> sleep (5*60);
> # Awake, now script resumes
> 
> See "perldoc -f sleep" for additional details.
> 
> *--------------------------------------------------------------------------*
> | Tim Maher, PhD     (206) 781-UNIX      (866) DOC-PERL     (866) DOC-UNIX |
> | tim(AT)Consultix-Inc.Com  http://TeachMePerl.Com  http://TeachMeUnix.Com |
> *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-*
> |    Watch for my Fall, 2005 book: "Minimal Perl for UNIX/Linux People"    |
> |  See http://minimalperl.com for details, ordering, and email-list signup |
> *--------------------------------------------------------------------------*
> _____________________________________________________________
> Seattle Perl Users Group Mailing List  
>      POST TO: spug-list at pm.org
> SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
>     MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med
>     WEB PAGE: http://seattleperl.org/



More information about the spug-list mailing list