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