`

一个清理归档的脚本!

 
阅读更多

导入500G的数据要产生很多归档,经常将归档的文件系统搞到100%。

关闭归档要重启数据库。所以用下面这个脚本一小时检查一下。

$ vi rm*.sh
"rm_arch.sh" 28 lines, 840 characters
#Please change the ARCHIVE_FS to your actual filesystem

ARCHIVE_FS=/oracle_archive

#Please change the ARCHIVE_DIR to your actual directory
ARCHIVE_DIR=/oracle_archive/RPTS

#Defined the location of log file
LOG=/orabackup3/henry/rm_arch/${0}.`date +%m%d`.log

#Obtain the usage of filesystem at that time
DFK=`df -k|grep $ARCHIVE_FS|awk '{USAGE=substr($5,1,length($5) - 1)

print USAGE}'`

#Check the usage of ARCHIVE_FS
if [ $DFK -gt80 ]
then
TIME=`date`
echo "At the time: "$TIME", Usage of " $ARCHIVE_FS "filesystem is beyond 80%. The used rate is :"$DFK"% now" >>$LOG
cd $ARCHIVE_DIR
fi
#Obtain file list that need to be remove
FILE_LIST=`ls -lt|tail -6|awk '{print $9}'`
for FILE in $FILE_LIST
do
echo $FILE "was removed at the time: " $TIME >>$LOG
rm $FILE 2>>$LOG
done

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics