Script for cropping down the domlogs

#!/bin/bash

for domain in /usr/local/apache/domlogs/*;
do
# Find the domain having more than 100 Mb log file size

if [ 3000 -lt `du $domain | awk {‘print $1’} 2> /dev/null` ]
then
{
echo $domain;

echo “splitting the file into sizes of 50 Mb each…”;

/usr/local/cpanel/bin/cpuwatch 7.0 split -b 2m $domain ${domain};

echo “Appending the last two sets of files generated”;

for i in `ls ${domain}a*| tail -n 2`;
do
tail -n 2 $i;echo $i;
cat $i >> ${domain}.test;
done

}
cp -f ${domain}.test ${domain};
rm -f ${domain}a* ${domain}.test;

echo “done”;
fi

done

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s