Professional Documents
Culture Documents
#!/bin/bash
#*********************************************************************
#* Author
: Venkata Suman
#* Purpose
: Auto zip log files in UNIX SERVERS
#* Date
: 20-03-2014
*
#*********************************************************************
#
*
*
echo " ======== Auto zip log files : `date|awk '{print $3 $2 ,$4}'`========">> $
{LOGFILE}
if [ $PC -gt $HWM ];then
echo "$FS is ${PC}% full ... proceeding to delete old archive log files .,. "
>>/tmp/autoclean.tmp
while [ $PC -gt $LWM ];do
file=`ls -t ${FS}/test* | tail -1`
echo " Auto zip log files ...`ls -l $file|awk '{print $6 ,$7 ,$8 ,$9 "[Size:",$5 "]"}'`" |tee -a
/tmp/autoclean.tmp >>${LOGFILE}
echo " Auto zip log files ...`ls -l $file|awk '{print $6 ,$7 ,$8 ,$9 "[Size:",$5 "]"}'`"
cp $file /tmp
gzip /tmp/test*
rm $file
cp /tmp/test*.gz ${FS}/
rm /tmp/test*.gz
sleep 1
echo " ............ zip log files " >> ${LOGFILE}
PC=`df -k ${FS}|awk -F" " '{print $5}'|tr -d "%"|tail -1 `
done
echo " $FS is ${PC}% full now. " >>/tmp/autoclean.tmp
cat /tmp/autoclean.tmp|mailx -s "Core files deleted ..." ${MAILTO}
rm /tmp/autoclean.tmp