Hi All,
I want to get the all ORA- related errors from attached logfile for previous day. Pls help. Thanks !
Regards
Kamal
Hi All,
I want to get the all ORA- related errors from attached logfile for previous day. Pls help. Thanks !
Regards
Kamal
Going by your requirement, a simple grep would suffice?
grep ORA alertlog_sample.txt
Thanks for the reply. simple grep statement will collect all the ORA- errors from alertlog file (Contains all records) .. But I need only previous day ORA- errors ...
This quick dirty one liner would look for previous day pattern (as given in the sample) and start reading till the end.
awk -v p="$(date --date '1 day ago' +'%a %b %d')" '$0 ~ p {f=1} f==1 && /ORA-/ {print}' alert_log_file
Does your script run daily ? or multiple times in a day?
I think, you don't want to repeat the alert if you already did. If that's your requirement, then you can probably do something like,
if ( last_line_no > total_current_lines ) {
# new alert_log file
# last_line=0
} else {
# normal processing
}
Hope it helps
Thanks for the reply. I am getting below error while using the above code
$ awk -v p="$(date --date '1 day ago' +'%a %b %d')" '$0 ~ p {f=1} f==1 && /ORA-/ {print}' alert_APDSPRD.log
date: illegal option -- date
usage: date [-u] mmddHHMM[[cc]yy][.SS]
date [-u] [+format]
date -a [-]sss[.fff]
awk: syntax error near line 1
awk: bailing out near line 1
$ uname -a
SunOS sgaygipora100 5.10 Generic_150400-03 sun4v sparc sun4v
You don't have GNU date. For non GNU, I have found this quick alternative. Try if that works
awk -v p="$(TZ=GMT+24; date +'%a %b %d')" '$0 ~ p {f=1} f==1 && /ORA-/ {print}' alert_APDSPRD.log
For a more robust solution, I suggest to use perl or search for various date arithmetic threads in this forum.
And on Solaris 10 use
/usr/xpg4/bin/awk
Thanks all for the reply !!! its working fine !!!