Hello, I have this script to gzip logs in different directories. Can some one check it for me. It works fine, but I want to make sure I did it correctly and the best way.
BTW, this is my frist script that I wrote. Thanks, Keith Olmstead #!/usr/bin/perl my $startdir = "/opt/log/hosts/"; use File::Find; use warnings; my @dirlist; $date=&getDate; @logfile = ("cron","messages","maillog","ldap"); foreach $log (@logfile) { find (\&eachFile, "$startdir"); } foreach $file(@log){ system("gzip $file") unless ($file =~ m/$date/); #print "$file done!\n" unless ($file =~ m/$date/); } # End for loop sub eachFile { if (-e $_ && $_ =~ /$log$/) { push @log, $File::Find::name;} } # End eachFile sub getDate { my ($sec, $min, $hour, $mday, $mon, $year) = localtime(time); $year = $year + 1900; $mon++; if ($mon < 10) {$mon = "0" . $mon;} if ($mday < 10) {$mday = "0" . $mday;} if ($hour < 10) {$hour = "0" . $mday;} if ($min < 10) {$min = "0" . $mday;} if ($sec < 10) {$sec = "0" . $mday;} $date = "\/$year\/$mon\/$mday\/"; return ($date); } # End getDate -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]