Perl Script to Rotate Apache log files
Posted by raxsoJul 25
Here is little perl script created by rhai of pinoytux.com on how to rotate apache log files.
Like this blog? Why not buy me a cup of coffee?#!/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`;}





![[hackers black book]](http://raxso.net/images/hbb-ani-misuse.gif)





I came across this blog the other day and you got some great info here - thanks.
[Reply]