I am trying to calculate the age of a log file. e.g.
The log file name will be in the format of 050927104522.log which is yymmddhhmmss.log
I need to check each log file and make sure that it is never 30 minutes old againts current date/time.
Explain:
Current datetime: 050927105522
List of log file: 050927104522.log,050927104222.log, 050927102022.log, 050927100000.log
Log file which is > 30 minutes old: 050927102022.log, 050927100000.log
(I need to remove those >30 minutes old)
I have a code (by pg) which gets current datetime and calculate the next 30 minutes
my $offset = 30; display(reverse((localtime(time()))[0 .. 5])); display(reverse((localtime(time() + 60 * $offset))[0 .. 5])); sub display { my @t = @_; printf("%d%02d%02d%02d%02d%02d\n", $t[0] + 1900, $t[1] + 1, @t +[2 .. 5]); }
How do i come about with this code where i can get the date from the log file name and add 30 minutes to it and compare againts the current date?
Cheers
Darren (Fellow Monk)
In reply to Time/date calculation by darrengan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |