#!/bin/bash
logfile="/usr/local/apache/domlogs/decenttools.com"
DATE=`date '+%Y-%m-%d'`
NEWFILE="/home/domlogs/decent/decenttools.com.${DATE}"
if [[ `du $logfile | awk {'print $1'}` > 500000 ]]; then
echo "Log is over 500 MB, rotating..."
cp $logfile $NEWFILE && gzip -9 $NEWFILE
cat /dev/null > $logfile
else
echo "Log file is too small, skipping."
fi