my $duration = 1000000; # in seconds my $wait = $duration; while ($wait >= 0) { $cmd1; $cmd2; $cmd3; $wait = $duration-time;#Decrement the time till it executed $cmd3 with $duration }