#!/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