26 October 2015

Cleanup trace files

Oracle trace files can be useful for tracing great deal of useful information, but same time, fills up the mount pretty soon, if you have active trace.

# Cleanup trace files more than 7 days old

root> find $DBA/$ORACLE_SID/bdump/*.trc -mtime +7 -exec rm {} \;
root> find $DBA/$ORACLE_SID/udump/*.trc -mtime +7 -exec rm {} \;
root> find $DBA/$ORACLE_SID/cdump/*.trc -mtime +7 -exec rm {} \;


Note that the first part of this script (before the –exec) displays all trace files that are more than 7 days old.
root> find $DBA/$ORACLE_SID/bdump/*.trc -mtime +7

/u01/app/oracle/admin/janet1/bdump/janet1_arc0_25005.trc
/u01/app/oracle/admin/janet1/bdump/janet1_arc0_25173.trc
/u01/app/oracle/admin/janet1/bdump/janet1_arc0_9312.trc
/u01/app/oracle/admin/janet1/bdump/janet1_arc0_9425.trc
/u01/app/oracle/admin/janet1/bdump/janet1_arc1_14300.trc
/u01/app/oracle/admin/janet1/bdump/janet1_arc2_14380.trc
/u01/app/oracle/admin/janet1/bdump/janet1_pmon_25159.trc
/u01/app/oracle/admin/janet1/bdump/janet1_snp0_25171.trc
/u01/app/oracle/admin/janet1/bdump/janet1_snp0_8188.trc

then the second part executes the rm command to remove the 'so found' files in the first part of the above script.

You can also remove files based on dates, for example, the files generated on Sep 27 will be deleted from the current directory.

rm -rf `ls -lt | grep 'Sep 27' | awk '{print $9}'`

No comments:

Post a Comment