in reply to Re: Run code every 6seconde
in thread Run code every 6seconde
This still has all the caveats of using sleep (may sleep longer, may be terminated by a signal, may actually sleep for a second if the argument is 0), but it won't miss its "slot" if a run of FONCTION1(); FONCTION2() takes more than 6 seconds.my $next = time; while (1) { $next = time if $next < time; $next += 6; FONCTION1; FONCTION2; sleep $next - time; }
|
|---|