数据库的目录超过85%报警并且自动删除目录里的归档文件,当然如果已经有备份程序在运行就不自动删除。
SCRIPT_PATH=/XXXXXX/arch
ARC_FS=/XXX
ARC_FILE=${ARC_FS}/XXXXX/*.arc
FSCK_P=85
LCOUNT=0
FSCK="`df -P|grep $ARC_FS|awk '{print$4}'|grep "%"|cut -d "%" -f 1`"
PCOUNT_1="`ps -ef|grep YYYY_t|grep -v grep|wc -l`"
PCOUNT_2="`ps -ef|grep YYYY_bk|grep -v grep|wc -l`"
delete_archivelog()
(
ls -tr $ARC_FILE > $SCRIPT_PATH/archlist_tmp
COUNT=`wc -l < $SCRIPT_PATH/archlist_tmp`
let COUNT=$COUNT-5
head -$COUNT $SCRIPT_PATH/archlist_tmp>$SCRIPT_PATH/filetodelete
/* 以下的一个命令是一行*/
cat $SCRIPT_PATH/filetodelete|awk '{print$1}'|awk -F "\b" '{ print "rm -f " $1 }' > $SCRIPT_PATH/filedeleted
sh $SCRIPT_PATH/filedeleted
return
)
########## MAIN ##########
if [ $FSCK -gt $FSCK_P ]
then
wlog CDSK911 "Warning! The XXXX archive directory /XXXXXX/archive is reach 85% now!"
if [ $PCOUNT_1 -gt $LCOUNT ]&&[ $PCOUNT_2 -gt $LCOUNT ]
then
wlog CDSK912 "The system will automatically delete archive files and left last 5 files"
delete_archivelog
fi
fi
rm -f $SCRIPT_PATH/archlist_tmp
rm -f $SCRIPT_PATH/filetodelete
rm -f $SCRIPT_PATH/filedeleted
阅读(1287) | 评论(0) | 转发(0) |