Cleanup Oracle ADR trace files on Linux


Here's a nice loop cleanup the Oracle DB trace files on Linux with the adrci utility.

#!/bin/bash
#cleanup Automatic Diagnostic Repository (i.e trace files)

#set oracle_home (have a script with your home info)
source ~/OracleHomeScript.sh

#list current repo size
echo ""
echo "##############size before############"
du -shx /u01/app/oracle/diag

echo ""
echo "Listing diag directory homes..."
echo ""
ADR_HOMES=`adrci exec="show homes" |grep -v "ADR Homes:"`
adrci exec="show homes" |grep -v "ADR Homes:"
echo ""
echo ""

#Set-up loop for each home
#

for f in $ADR_HOMES
do
echo "purging $f older than 1 week"
#Slow ADRCI Execution When Purging Files After Upgrade to 12.2 (Doc ID 2335738.1)
adrci exec="set homepath $f; purge -age 10080 -nolog"
done

#list ADR repo size after
echo ""
echo "##############size after############"
du -shx /u01/app/oracle/diag

######################END OF SCRIPT##########################


Now to cleanup the listener.log file, good ol unix logrotate

##########NOTE FOR DEALING WITH listener.log ###############
####to rotate the listener.log file using unix log rotate##########
#1. Create a file in this path /etc/logrotate.d/oracle
#
#-- write this lines into that file:
#/u01/app/oracle/diag/tnslsnr/myhost/listener/trace/listener.log {
#missingok
#weekly
#rotate 52
#notifempty
#compress
#missingok
#copytruncate
#create 644 oracle dba
#}

Comments

Popular posts from this blog

Create a custom backup report with BI Publisher for Oracle Enterprise Manager/Cloud Control 13c

Active Directory Authentication with an Oracle Database

Oracle Enterprise Manager notify when Recovery Area low