Trace and trm files cleanup script
#By : Anil Vejendla
Trace & Trm files cleanup older than 30 days
export ORAENV_ASK='NO'
#for ORACLE_SID in `ps -ef | grep pmon | grep -v grep | cut -d '_' -f 3-`;do
for ORACLE_SID in `egrep -v '^[ \t]*$|^#' /etc/oratab | cut -d ':' -f 1`;do
export ORACLE_SID
. oraenv > /dev/null
echo "
==============================================
Trace files .trc & .trm removal for $ORACLE_SID:
==============================================
"
bdump=`sqlplus -s / as sysdba <<EOF
set head off;
set feedback off;
set verify off;
select value from v\\$parameter where name='background_dump_dest';
EOF`
echo $bdump
# Make sure the directories are valid and cleanup the files
if [ -d ${bdump} ]; then
echo "Removing old files at `date +%Y%m%d%H%M` for ${ORACLE_SID}" ;
echo "No of trace files Before Cleanup `ls -l ${bdump} | wc -l`";
echo "Disk Size Before Cleanup `df -kh ${bdump} | tail -1 | awk '{ print $4 }' `";
find ${bdump} -mtime +30 -name "*.trc" -type f -exec rm {} \;
find ${bdump} -mtime +30 -name "*.trm" -type f -exec rm {} \;
echo "No of trace files After Cleanup `ls -l ${bdump} | wc -l`";
echo "Disk Size After Cleanup `df -kh ${bdump} | tail -1 | awk '{ print $4 }' `";
fi;
done
unset ORAENV_ASK
Comments
Post a Comment