#! /usr/bin/ksh
LOGPATH=/var/support/log/
LOGFILE=$LOGPATH/spaceclean.log
RECIPIENTS=vivek.tiwari@home.com
HOSTNAME=`hostname`
app_name=/base_path/
echo "Cleaning/Compressing log files\n\n\n " >$LOGFILE
echo "============================================================================================\n\n\n" >> $LOGFILE
logPath=/targ_dir/logs/logserver_output
echo "Compresssing below logs older than 2days" >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
find $logPath -type f -mtime +2 ! \( -name filename -o -name *.gz \) -print >> $LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
find $logPath -type f -mtime +2 ! \( -name filename -o -name *.gz \) -exec gzip {} \; >>$LOGFILE
if [ $? -eq 1 ]; then
echo "Unable to compress the logs at $logPath\n" >> $LOGFILE
else
echo "Log Compression Successfull at $logPath\n" >> $LOGFILE
fi
echo "Removing below logs older than 90days" >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
find $logPath -type f -mtime +90 -exec ls -ltr {} \; >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
find $logPath -type f -mtime +90 -exec rm -rf {} \;
if [ $? -eq 1 ]; then
echo "Unable to delete the logs at $logPath\n" >> $LOGFILE
else
echo "Removing of 90days old log files Successfull at $logPath\n" >> $LOGFILE
fi
OtherlogPath2=/targ_dir/logs/dgraphs
echo "compressing below logs older than 1 days from $OtherlogPath2" >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
find $OtherlogPath2 -type f -mtime +1 ! \( -name ".*" -o -name *.gz \) -print >> $LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
echo "Compression Started at $OtherlogPath2 for logs" >>$LOGFILE
find $OtherlogPath2 -type f -mtime +1 ! \( -name ".*" -o -name *.gz \) -print -exec gzip {} \; >>$LOGFILE
if [ $? -eq 1 ]; then
echo "Unable to compress the logs at $OtherlogPath2 \n" >> $LOGFILE
else
echo "Compression folder_name at $OtherlogPath2 for (*.reqlog.*) logs" >>$LOGFILE
fi
echo "\n==========================================================================================\n" >> $LOGFILE
per=`df -h /var/opt | tail -1 | awk '{print $4}'`
df -h /var/opt >> $LOGFILE
echo "Removing Report logs older than 30days" >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
#find $app_name/1_report -type f -mtime +30 -exec ls -ltr {} \; >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
echo "Removing Report logs older than 30days" >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
#find $app_name/2_report -type f -mtime +30 -exec ls -ltr {} \; >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
echo "Removing Report logs older than 30days" >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
#find $app_name/3_report -type f -mtime +30 -exec ls -ltr {} \; >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
mailx -s "On $HOSTNAME the file system is now $per" $RECIPIENTS < $LOGFILE
LOGPATH=/var/support/log/
LOGFILE=$LOGPATH/spaceclean.log
RECIPIENTS=vivek.tiwari@home.com
HOSTNAME=`hostname`
app_name=/base_path/
echo "Cleaning/Compressing log files\n\n\n " >$LOGFILE
echo "============================================================================================\n\n\n" >> $LOGFILE
logPath=/targ_dir/logs/logserver_output
echo "Compresssing below logs older than 2days" >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
find $logPath -type f -mtime +2 ! \( -name filename -o -name *.gz \) -print >> $LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
find $logPath -type f -mtime +2 ! \( -name filename -o -name *.gz \) -exec gzip {} \; >>$LOGFILE
if [ $? -eq 1 ]; then
echo "Unable to compress the logs at $logPath\n" >> $LOGFILE
else
echo "Log Compression Successfull at $logPath\n" >> $LOGFILE
fi
echo "Removing below logs older than 90days" >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
find $logPath -type f -mtime +90 -exec ls -ltr {} \; >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
find $logPath -type f -mtime +90 -exec rm -rf {} \;
if [ $? -eq 1 ]; then
echo "Unable to delete the logs at $logPath\n" >> $LOGFILE
else
echo "Removing of 90days old log files Successfull at $logPath\n" >> $LOGFILE
fi
OtherlogPath2=/targ_dir/logs/dgraphs
echo "compressing below logs older than 1 days from $OtherlogPath2" >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
find $OtherlogPath2 -type f -mtime +1 ! \( -name ".*" -o -name *.gz \) -print >> $LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
echo "Compression Started at $OtherlogPath2 for logs" >>$LOGFILE
find $OtherlogPath2 -type f -mtime +1 ! \( -name ".*" -o -name *.gz \) -print -exec gzip {} \; >>$LOGFILE
if [ $? -eq 1 ]; then
echo "Unable to compress the logs at $OtherlogPath2 \n" >> $LOGFILE
else
echo "Compression folder_name at $OtherlogPath2 for (*.reqlog.*) logs" >>$LOGFILE
fi
echo "\n==========================================================================================\n" >> $LOGFILE
per=`df -h /var/opt | tail -1 | awk '{print $4}'`
df -h /var/opt >> $LOGFILE
echo "Removing Report logs older than 30days" >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
#find $app_name/1_report -type f -mtime +30 -exec ls -ltr {} \; >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
echo "Removing Report logs older than 30days" >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
#find $app_name/2_report -type f -mtime +30 -exec ls -ltr {} \; >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
echo "Removing Report logs older than 30days" >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
#find $app_name/3_report -type f -mtime +30 -exec ls -ltr {} \; >>$LOGFILE
echo "\n==========================================================================================\n" >> $LOGFILE
mailx -s "On $HOSTNAME the file system is now $per" $RECIPIENTS < $LOGFILE
No comments:
Post a Comment