How can I time out 5 minutes?
My program does this:
$maxtime = time() + (5 * 60);
$success = 0;
while (($success == 0) && (time() < $maxtime)) {
$success = try_something();
sleep (3) if ($success == 0);
}
Problem: This program starts immediately after loading. The built-in system in which it works does not have an rtc / clock battery. The clock starts in January / 1/2000, then in the first minute it starts, it receives a network, and ntp sets the clock to the updated clock, making the loop exit before the timeout of 5 minutes.
What is the correct way to "count 5 minutes" inside a perl script, even if the system clock is changed by another external program?
source
share