Hello,
I am neeing some help on a script that I am writing. Here is what I have so far:
my $startdir = "/opt/log/hosts/";
use File::Find;
#use strict;
use warnings;
my @dirlist;
@logfile = ("cron","messages","maillog","ldap");
foreach $log (@logfile) {
sub eachFile {
if (-e $_ && $_ =~ /$log$/) { push @log, $File::Find::name;}
}
find (\&eachFile, "$startdir");
}
foreach $file(@log){
#system("gzip $file");
print "$file done!\n";
}
It currently looks for @logfile and then gzips them. What I am needing help with now
is this. It gzips all the files, and I only want it to gzip the files from the
previous day. Here is an example of what it finds..
/opt/log/hosts/server_ip/2003/08/04/maillog done!
/opt/log/hosts/server_ip/2003/08/03/maillog done!
/opt/log/hosts/server_ip/2003/08/02/maillog done!
/opt/log/hosts/server_ip/2003/08/01/maillog done!
/opt/log/hosts/server_ip/2003/07/31/maillog done!
Whenever the date changes to the next day, then a new dir is created and new log files
are written to that dir.
An Idea that I had was to check the current date against the date # in the dir, ie 31,
01, 02.. from above and if the current date does not equal that number then gzip the
files in it.
How does this sound? Is there a better way to do this?
Thanks,
Keith
--
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]