Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 E-mail Us
 Oracle Articles
New Oracle Articles

 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog

 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Oracle Support

 SQL Tuning

 Oracle UNIX
 Oracle Linux
 Remote s
 Remote plans
 Application Server

 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S


 Consulting Staff
 Consulting Prices
 Help Wanted!


 Oracle Posters
 Oracle Books

 Oracle Scripts

Don Burleson Blog 








Oracle Linux - Using the "find" command to manage files

Oracle Database Tips by Donald BurlesonConsulting

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. Please note that in chapter 8 we extend this command to search for all files that contain specific strings:

root> pwd

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.
root> find $DBA/$ORACLE_SID/bdump/*.trc -mtime +7


Find recent Oracle files

This section issues the UNIX/Linux find command to locate any Oracle trace or dump files that were created in the past day:

# list the full-names of all possible dump files . . . .
find $DBA/$ORACLE_SID/bdump/*.trc -mtime -1 -print >> /tmp/trace_list.lst
find $DBA/$ORACLE_SID/udump/*.trc -mtime -1 -print >> /tmp/trace_list.lst
find $ORACLE_HOME/rdbms/log/*.trc -mtime -1 -print >> /tmp/trace_list.lst

Because we know that the grep commands accepts file names as an argument, we can use UNIX xargs command to search each file for our Oracle table name in all sql files. In this case, we search the whole Oracle UNIX directory structure and quickly find all scripts that reference the dba_2pc_pending view.

root> find . -print|grep sql|xargs grep -i dba_2pc_pending

./sql/PENDING.sql:from dba_2pc_pending

Locate recently created Oracle Linux files

The following command is useful for finding Linux files that have been recently added to your server.  Part of the job of the Oracle DBA is monitoring the background_dump_dest and the user_dump_dest for trace files, and purging trace files that are no longer required.

The following command lists all files that were created in the past two weeks:

root> find . -mtime -14 -print

This command can easily be expanded with the xargs or the ?exec command to automatically remove the elderly trace files:

root> find . -mtime -14 -print|xargs -i rm \;

Note: In Windows you can use this equivalent to the UNIX -mtime check, see equivalent of UNIX mtime for Windows

Finding large files on Linux

The following command is very useful in cases where a Linux file system has become full.  As we may know, Oracle will hang whenever Oracle must expand a tablespace and Oracle cannot extend the UNIX filesystem.

When a UNIX file become unexpectedly full, it may be because Oracle has written a huge core or trace file into the UNIX filesystem.

The script below will display all files that are greaten then one megabyte in size.  Note that the size parameter is specified in K-bytes.

root> find . -size +1024 ?print


Of course, you can easily append the xargs of ?exec command to automatically remove the large file:

root> find . -size +1024 ?print|xargs ?i rm \;

This find command will do a "stats" on all files in a directory structure, showing the total size of all files in the directory.  You can also incorporate the "df -k" command"

find ${START_DIR} -mtime -${DAYS} |xargs stat -c "%s"|awk '{sum += $1}END{print sum}'

If you like Oracle tuning, see the book "Oracle Tuning: The Definitive Reference", with 950 pages of tuning tips and scripts. 

You can buy it direct from the publisher for 30%-off and get instant access to the code depot of Oracle tuning scripts.



Oracle Training at Sea
oracle dba poster

Follow us on Twitter 
Oracle performance tuning software 
Oracle Linux poster


Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  and include the URL for the page.


Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


Copyright © 1996 -  2016

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.