Discussion Locked
0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
i wanna access all logs file in a directory which are created on different dates , i want to get the logs file between specific period of dates and then process them . so please let me know how can i check the creation date to the logs , take the logs between the given period and the process them
1 reply
try the following:
use Time::Local;
opendir(DIR, "/path/to/directory");
# convert date Midnight 3 Mar 04
$start_time = timelocal(0,0,0,3,2,2004);
# convert date Midnight 3 Mar 05
$end_time = timelocal(0,0,0,3,2,2005);
while ($name = readdir(DIR)) {
next if (-d "/path/to/directory/" . $name);
# get creation time
$time = (stat("/path/to/directory" . $name))[10];
if (($time >= $start_time) && ($time < $end_time)) {
# process file. This file was created on an after
# the first dateand before the second date.
}
}
closedir(DIR);
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending
1 helpful
9 replies
Question
Windows and macOS computers becoming slow or unstable after updates - what should I check first
0 helpful
1 reply
0 helpful
3 replies
Discussion
Optimizing WordPress widgets and DOM size
0 helpful
3 replies
Discussion Locked
Best Ways to Improve Website Visibility
0 helpful
5 replies