Handy Automatic Archivelog purge Script

 Here is simple snippet of Code to Purge Archivelogs automatically every hour. Can be utilized greatly during bulk load etc. Better option would be in that case to put the DB in noarchivelog mode. 

_qa_[oracle@eecql0119b3gs8 20:55:07 scripts]$ cat /oracle_shared/DBA/scripts/purge_archivelog.sh

#!/bin/bash

set -x

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=/u01/app/oracle/paytest/19.0.0

export ORACLE_SID=paytest

export PATH=$PATH:$ORACLE_HOME/bin


rman target / << __EOF__

DELETE NOPROMPT ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE -1/24';

EXIT

__EOF__


Its time to schedule in cron


_qa_[oracle@eecql0139248 20:55:11 scripts]$ crontab -l

#executes every hour 55th minute

55 * * * * source /home/oracle/.bash_profile; sh /oracle_shared/DBA/scripts/purge_archivelog.sh > /tmp/purge_archivelog.log 2>&1

_qa_[oracle@eecql0139248 20:55:13 scripts]$


No comments: