Home 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 Analysis Design Implementation Oracle Support SQL Tuning Security Oracle UNIX Oracle Linux Monitoring Remote support Remote plans Remote services Application Server Applications Oracle Forms Oracle Portal App Upgrades SQL Server Oracle Concepts Software Support Remote Support Development Implementation Consulting Staff Consulting Prices Help Wanted! Oracle Posters Oracle Books Oracle Scripts Ion Excel-DB |
This is an excerpt from the book 'Oracle Shell Scripting', a great source of UNIX scripts for file management. 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 /u01/home/oracle/product/9.1.2/bin/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 ./oracle/product/9.1.2/rdbms/admin/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 /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 |