We need to delete archivelogs which are applied on standby servers. Following script will do the job for you.

  1. vi /home/oracle/crons/remove_applied_archivelog.sh
#!/bin/ksh
#
#
# Remove applied archivelog all;
#
# 
ORACLE_SID=ORCL; export ORACLE_SID
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1; export ORACLE_HOME

tmpfile=/tmp/arch_id.tmp

$ORACLE_HOME/bin/sqlplus -S /nolog <<EOF > $tmpfile
connect / as sysdba
set head off
set pages 0
select max(sequence#) from v\$archived_log where applied = 'YES';
exit
EOF

echo DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = `head -n 1  $tmpfile | awk '{print $1}'` ';' > $tmpfile

$ORACLE_HOME/bin/rman target / <<EOF
 @$tmpfile
exit
EOF

2. Give executable permission to the file

chmod +x /home/oracle/crons/remove_applied_archivelog.sh

3. Add to cron. It runs everyday at 22:05

crontab -e
5 22 * * */home/oracle/crons/remove_applied_archivelog.sh

 

Tagged:

About The Author

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.