Linux下清理备份oracle监听日志脚本

#!/bin/sh
#Auto remove and backup listener.log
#Author  xyarn
#Date 2018-7-13 14:38:58

filepath=/app/oracle/diag/tnslsnr/oracledb/listener/trace
filename=listener.log
zipname=HistoryListener.zip
filesize=`ls -l $filepath/$filename |awk '{print $5}'`
maxsize=$((1230354730))
if [ $filesize -gt $maxsize ]
then
    echo "$filesize > $maxsize"
    set log_status off
    sleep 5s
    mv $filepath/$filename  $filepath/listener.old"`date +%Y-%m-%d_%H:%M:%S`"
    set log_status on
    zip $filepath/$zipname  $filepath/listener.old*
    sleep 240s
    rm   $filepath/listener.old*
else
    echo "$filesize < $maxsize , No need to move!"
fi

 

posted @ 2018-10-08 15:27  xyarn  阅读(696)  评论(0编辑  收藏  举报
//https://esofar.github.io/cnblogs-theme-silence/#/guide