Script to clean up Oracle trace & dump files

The UNIX/Linux “find” command can be used to locate any external Oracle files including database files (dbf), alert log files, and all trace and dump files.  The “which” command can also find files, and we can easily find the location of the SQL*Plus executable:

root> which sqlplus

For non-executable files, you can use the UNIX find command to locate a particular file.

root> cd /
root> find . -print|grep –i dbmspool.sql

In the example above, we cd to the root directory (/) and issue a UNIX find command to display every file on the Oracle server.  Next, we pipe the output of the find command to grep, which searches for the dbmspool.sql file.

Below is a script that will automatically remove all trace files from the background_dump_destination filesystem in UNIX.

# 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.

Be the first to comment

Leave a Reply

Your email address will not be published.