自动清理DataGuard备机日志

>> from zhuhaiqing.info

#!/usr/bin/bash
#删除DataGuard备机归档日志备份

export ORACLE_HOME=/opt/oracle/product/10.2.0/Db_1
export ORACLE_SID=starboss
export ARC_DIR=/home/oracle/arch
export DBID=927537571
 
del_seq=`ls $ARC_DIR/|head -1|cut -f2 -d_`
echo $del_seq
$ORACLE_HOME/bin/sqlplus "/ as sysdba" <<eof >$ARC_DIR/max_sn.log
set head off;
set feedback;
select max(sequence#) from v\$log_history;
exit;
eof
max_sn=`cat $ARC_DIR/max_sn.log|awk '{print $1}'|grep ^[0-9]`
max_sn=`expr $max_sn - 30`
echo $max_sn
while [ $del_seq -lt $max_sn ]
do
  rm -rf $ARC_DIR/1_"$del_seq"_$DBID.arc
  del_seq=`expr $del_seq + 1`
  echo $del_seq
done

 

posted @ 2016-08-20 12:46  皮er  阅读(531)  评论(0编辑  收藏  举报