Oracle archive log cleanup script

Here’s a quick bash script to clean up archive logs older than a week. It reads the Oracle SIDs from /etc/oratab and invokes rman for each SID. One could put this in cron to be run once a day to keep disk space usage in check.

# clean up old archive logs

# save the original PATH

# function which calls RMAN and deletes old logs
doit ()
rman target / <<HERE
delete noprompt archivelog until time ‘sysdate-7’;

# doit for each SID in /etc/oratab
for l in `grep -v ‘^#’ /etc/oratab`; do
export ORACLE_SID=`echo $l | cut -d: -f1`
export ORACLE_HOME=`echo $l | cut -d: -f2`

Leave a Reply

Your email address will not be published. Required fields are marked *

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