Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Shell script to split Apache domlogs in cPanel server  (Read 2508 times)

0 Members and 1 Guest are viewing this topic.

lathu_official

  • Guest
Shell script to split Apache domlogs in cPanel server
« on: January 26, 2014, 06:36:02 am »
#!/bin/bash
for domain in /usr/local/apache/domlogs/*;
do
# Find the domain having more than 100 Mb log file size
if [ 100000 -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 5.0 split -b 50m $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

-----------
Thanks