Wednesday, November 19, 2008

Log delete

#!/bin/bash
#
# Delete Torque log files which are older than 7days in cylone.
# Date 18th Sep 2008
# Umaknata Samantaray.
#
#
TORQUEACCLOG=/opt/torque/server_priv/accounting
TORQUESERLOG=/opt/torque/server_logs

if [ -d $TORQUEACCLOG ] ; then
cd $TORQUEACCLOG && find . -type f -name '*' -mtime +7 -exec rm {} \;
else
echo $TORQUEACCLOG does not exist.
fi

if [ -d $TORQUESERLOG ] ; then
cd $TORQUESERLOG && find . -type f -name '*' -mtime +7 -exec rm {} \;
else
echo $TORQUESERLOG does not exist.
fi




#!/bin/bash
# Reduce the size to 0 if the size of moab.log is more than 1GB
# Date 18th Sep 2008
# Umakanta Samantaray
#
MOABLOGPATH=/opt/moab/log
FILE=moab.log
if [ -d $MOABLOGPATH ] ; then
{
SIZE=`du -sk ${MOABLOGPATH}/${FILE} | cut -d'/' -f1`
if [ ${SIZE} -ge 1048576 ] ; then
cat /dev/null > ${MOABLOGPATH}/${file}
else
echo "Size of ${FILE} is less than 1GB."
fi
}
else
echo "${MOABLOGPATH} does not exist."
fi

No comments: