darrengan has asked for the wisdom of the Perl Monks concerning the following question:
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)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Time/date calculation
by pg (Canon) on Sep 27, 2005 at 03:39 UTC | |
|
Re: Time/date calculation
by monarch (Priest) on Sep 27, 2005 at 02:58 UTC | |
|
Re: Time/date calculation
by graff (Chancellor) on Sep 27, 2005 at 03:26 UTC | |
|
Re: Time/date calculation
by davidrw (Prior) on Sep 27, 2005 at 03:39 UTC | |
|
Re: Time/date calculation
by tomazos (Deacon) on Sep 27, 2005 at 05:26 UTC | |
|
Re: Time/date calculation
by blazar (Canon) on Sep 27, 2005 at 10:16 UTC | |
|
Re: Time/date calculation
by darrengan (Sexton) on Sep 28, 2005 at 02:06 UTC |