#! /bin/ksh

cd /twc/log

FILE_LST=`find . -size 0c -mtime +1 | tr -s "\n" " "`
for i in $FILE_LST; do
    echo "Deleting 0 length file $i"
    rm $i
done
    
FILE_LST=`find . -name "*.log" -mtime +1 | tr -s "\n" " "`
curDate=`date +%m%d%y`
curTime=`date +%H%M`

for i in $FILE_LST; do
    arcName=`echo $i | sed -e s:.log:.${curDate}_$curTime.log.bak:`
    echo "Renaming $i to $arcName"
    mv $i $arcName
done

FILE_LST=`find . -atime +30 -name "*.old" | tr -s "\n" " "`
for i in $FILE_LST; do
    echo "Removing old file $i"
    rm $i
done

FILE_LST=`find . -atime +30 -name "*.bak" | tr -s "\n" " "`
for i in $FILE_LST; do
    echo "Removing old file $i"
    rm $i
done



