Email alert log ORA: errors

#!/bin/ksh
SERVICE=’ora_pmon_SWX’
if ps -ef | grep -v grep | grep $SERVICE > /dev/null
then
#. $HOME/shell/.swx_profile
. $HOME/.profile
cd /u1/oracle/OraSWX/admin/SWX/bdump
rm -f alert.err
rm -f alert_work.log
if [ -f alert_${ORACLE_SID}.log ]
then
mv alert_${ORACLE_SID}.log alert_work.log
touch alert_${ORACLE_SID}.log
cat alert_work.log >> alert_${ORACLE_SID}.hist
grep ORA- alert_work.log > alert.err
fi
if [ `cat /u1/oracle/OraSWX/admin/SWX/bdump/alert.err|wc -l` -gt 0 ]
then
cd  /u1/oracle/OraSWX/admin/SWX/bdump|mailx -s “`hostname`:${ORACLE_SID}:Error in Alert Logfile `date`” abc@xyz.com </u1/oracle/OraSWX/admin/SWX/bdump/alert.err
fi
else
echo “$SERVICE is not running”
fi

Advertisements

3 thoughts on “Email alert log ORA: errors

  1. I would rework the script this way.. remove the “touch” and “mv” and I will truncate the existing alert log using cat instead of using mv and touching a new file.

    ====================================
    if [ -f alert_${ORACLE_SID}.log ]
    then
    cat alert_work.log >> alert_${ORACLE_SID}.hist
    grep ORA- alert_work.log > alert.err
    cat /dev/null > alert_${ORACLE_SID}.log

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s