I have to generate automated script for alert log file, which will display the contents of alert log file. Here is the script for that.
while :
clear
do
echo "\n"
echo "ORA - Error"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
sed -n "/ORA-/p" "alert log fiel path"
sleep 4
clear
My issue is that I am getting all the errors. I only want errors which occured today. How can I do this?
Best Answer
1) If you are using Oracle 11g or later:
Starting from 11g Oracle, was been introduced a fixed table, X$DBGALERTEXT, from which you can retrieve all the data what alert.log does. Here is a simple query that retrieves all errors which occured today, like you want.
As Twinkles mentioned in his answer, you can take advantage of ADRCI utility to select alert filters that you need (in fact, this utility queries against the X$DBGALERTEXT table). For example, you can build a simple function and call it from OS prompt:
in file .bashrc, for example:
Then:
2) Otherwise:
Go and have a look at this web page. There is a script that can be used to check any ORA- errors are there in the alertlog file for the present day.
To schedule this job, you can add a line in your cron table specifying the time you want the job to execute. Alternatively, you can take advantage of the Oracle Scheduler.