my @time = localtime; $control->log("Starting Curtain Controller") if $DEBUG > 1; # Check Pi has valid time my $wait = 1; while ($time[5] + 1900 < 2020) { if ($wait > 30) { $control->log("Still no valid time. Aborting!"); sleep(2); system("sudo reboot"); exit 0; } my $plural = $wait == 1?'':'s'; $control->log("No valid time. Waiting $wait minute$plural"); print "Waiting for $wait minutes$plural\n" if $DEBUG; sleep ($wait * 60); $wait = int(0.5 + $wait * 1.5); @time = localtime; }