dataguard删除归档日志的脚本

 

#!/bin/bash
#Author: Baililin 2018/11/26
#Description:Delete the archived logs which had applied on Standby database.
source /home/oracle/.bash_profile
logfile=/tmp/rman_del_arch.log
getsql(){
sqlplus -S "/as sysdba" <<EOF
set head off
set feedback off
select 'delete noprompt archivelog from sequence 0 until sequence '||max(sequence# - 10)|| ' thread ' || thread# ||';' 
  from v\$archived_log where applied='YES' group by thread#;
exit
EOF
}
delArch(){
sql=$(getsql)
rman target / log=${logfile} append <<EOF
$sql
exit;
EOF
}
delArch

  

posted @ 2018-11-26 11:12  ^^Tom^^  阅读(566)  评论(0编辑  收藏  举报