#!/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