#!/usr/bin/perl -w
use strict;
my $runtime = 3600;
my $runtime2;
my $nextruntime = 0;
my $days = int($runtime / 86400);
$runtime -= ($days * 86400);
my $hours = int($runtime / 3600);
$runtime -= ($hours * 3600);
my $minutes = int($runtime / 60);
my $seconds = $runtime % 60;
$days = $days .'d ';
$hours = $hours .'h ';
$minutes = $minutes .'m ';
$runtime2 = $runtime;
$runtime2 = $days . $hours . $minutes . $seconds . 's';
if (time()>=$nextruntime){
$nextruntime=time()+300;
$runtime += 300;
print "Duration: $runtime2\n";
}
####
Duration: 0d 1h 0m 0s
####
Duration: 0d 0h 5m 0s
####
#!/usr/bin/perl -w
use strict;
my $start = time();
while (1) {
my $buffer = (time() - $start);
($buffer, my $seconds) = (int $buffer/60, $buffer % 60);
($buffer, my $minutes) = (int $buffer/60, $buffer % 60);
($buffer, my $hours) = (int $buffer/24, $buffer % 24);
my $days = $buffer;
print "Duration: ${days}d ${hours}h ${minutes}m ${seconds}s\n";
sleep (300);
}