Oracle Consulting Oracle Training Oracle Support Development
Oracle Books
SQL Server Books
IT Books
Job Interview Books
Rampant Horse Books
911 Series
Pedagogue Books

Oracle Software
Write for Rampant
Publish with Rampant
Rampant News
Rampant Authors
Rampant Staff
Oracle News
Oracle Forum
Oracle Tips
Articles by our Authors
Press Releases
SQL Server Books

Oracle 11g Books

Oracle tuning

Oracle training

Oracle support

Remote Oracle


Privacy Policy




Oracle Tips by Burleson 

Oracle Trace file Alert Report

This is a great script for instantly notifying the DBA and developers of the presence of trace files. In a production environment, this script can be used to alert the DBA to production aborts, and it is also useful in development environments, where developers can be e-mailed their trace file dumps when a program aborts. This script is generally executed every five minutes.

The trace_alert.ksh script interrogates the Oracle datafile systems to find the locations of all trace and dump files. It then checks these directories and e-mails any trace files to the appropriate staff member. Let’s take a close look at the steps in this script.

Set the Environment

The first part of the script ensures that a valid ORACLE_SID is passed to the script:


# Exit if no first parameter $1 is passed to script
if [ -z "$1" ]
echo "Usage: trace_alert.ksh <ORACLE_SID>"
exit 99

# First, we must set the environment . . . .
ORACLE_HOME=`cat /var/opt/oracle/oratab|grep $ORACLE_SID:|cut -f2 -d':'`
ORACLE_BASE=`echo $ORACLE_HOME | sed -e 's:/product/.*::g'`
export DBA=$ORACLE_BASE/admin;
export DBA
export PATH
MON=`echo ~oracle/mon`
export MON

Get the Names of Any Recent Trace or Dump Files

This section issues the UNIX 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

E-Mail the Trace Files

This section of the code extracts the first 100 lines of each trace and dump file and e-mails them to the DBA and developer staff.

# for each trace file found, send DBA an e-mail message
# and move the trace file to the /tmp directory
cat /tmp/trace_list.lst|while read TRACE_FILE

# This gets the short file name at the end of the full path
SHORT_TRACE_FILE_NAME=`echo $TRACE_FILE|awk -F"/" '{ print $NF }'`
# This gets the file location (bdump, udump, log)
DUMP_LOC=`echo $TRACE_FILE|awk -F"/" '{ print $(NF-1) }'`

# send an e-mail to the administrator

head -100 $TRACE_FILE|\
mailx -s "$ORACLE_SID Oracle trace file at $MYDATE."\\\


The above is an excerpt from the "Oracle9i UNIX Administration Handbook" by Oracle press, authored by Donald K. Burleson.


Download your Oracle scripts now:

The definitive Oracle Script collection for every Oracle professional DBA



Linux Oracle commands syntax poster

ION Oracle tuning software

Oracle data dictionary reference poster

Oracle Forum

BC Oracle consulting support training

BC remote Oracle DBA   



 Copyright © 1996 -2017 by Burleson. All rights reserved.

Oracle® is the registered trademark of Oracle Corporation. SQL Server® is the registered trademark of Microsoft Corporation. 
Many of the designations used by computer vendors to distinguish their products are claimed as Trademarks

Hit Counter