#!/usr/bin/perl -w # Wait until a specified timestamp. # # This is useful for starting synchronized jobs. use strict; die "$0 \n" unless $#ARGV == 0 && $ARGV[0] =~ /(\d+):(\d+):(\d+)/; my ($th, $tm, $ts) = ($1, $2, $3); $| = 1; for(;;) { my ($s, $m, $h) = localtime; printf "\r".'[%02d:%02d:%02d] - Waiting until %02d:%02d:%02d', $h, $m, $s, $th, $tm, $ts; last if $h == $th && $m == $tm && $s == $ts; my $d = $th * 3600 + $tm * 60 + $ts - ($h * 3600 + $m * 60 + $s); if( $d < 10 || $d > 86400 - 10 ) { sleep 0.1; } else { sleep 1; } } print "\n";