I put up a small script to delete old logs and at the same time rotating the logs. on my squid log directory ( I can use logrorate and unlink the logs, but I choose to test my ability to do that)

however, with my code below, I can see delete the old logs, however, the output of the log the squid rotated is not included when the unlink is being executed.

after runing the script, I will still find the newly rotated logs like access.log.0, store.log.0 etc in the directory.

I will be glad for any assisstance including hash comment

#!/usr/bin/perl
#
use warnings;
use strict;
use diagnostics;
use Time::HiRes;
#
my ($fname, @si);
##read the content of the directory and check there sizes.
opendir DIR, '/var/log/squid' or die "ko ri direk3 si: $!";
while($fname=readdir(DIR)){
    my @si = stat($fname);
        next, if $fname=~m/^[\.|\.\.]/;
system("squid", "-k", "rotate"), if ($si[7]=~/[1-9]\d{6,}/ && $fname=~/^([a-z]+\.log)$/);
        unlink $fname, if $fname=~m/(\S{3,}\.){2,3}/;
}

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to