Here is little perl script created by rhai of pinoytux.com on how to rotate apache log files.

#!/usr/bin/perl

$DIR=”/var/www/html/sites/yoursite.com/logs”;
$DATE=`date +%F`;
chomp $DATE;

@log = `/usr/bin/find $DIR -type f -name “*.log” `;

#print “\nRotating $DATE\n”;

foreach $log (@log) {
chomp $log;
$new_fn=”$log”.”-”.”$DATE”;
#print “$log $new_fn\n”;
`mv “$log” “$new_fn”`;
`gzip -9 $new_fn`;

}

Like this blog? Why not buy me a cup of coffee?