How to error script for a log file?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to error script for a log file?
# 1  
Old 10-22-2014
How to error script for a log file?

So, I have a log file I need to search for ORA- errors.

If the only errors are: ORA-39082|ORA-39083|ORA-01917 then the script should have executed okay.

If there are ORA- errors that are in the log file other than above, then I need to send a mail saying that the script failed.

Any ideas with you awk experts on maybe how to do this?
# 2  
Old 10-22-2014
You could use egrep like this:

Code:
egrep -o 'ORA-\S+' logfile |
egrep -qv '(39082|39083|01917)' && mail -s "The script failed" cougartrace@your.email.address <<EOF
Body of the email
message
EOF

---------- Post updated at 07:31 AM ---------- Previous update was at 07:01 AM ----------

and using awk:

Code:
awk '/ORA-/ { while(match($0, "ORA-\\S+")) {
    if(substr($0,RSTART,RLENGTH) !~ "(ORA-39082|ORA-39083|ORA-01917)")
        exit 1
    $0=substr($0,RSTART+RLENGTH)}}' logfile || mail ...


Last edited by Chubler_XL; 10-22-2014 at 06:18 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Print Error in Console and both Error & Output in Log file - UNIX

I am writing a shell script with 2 run time arguments. During the execution if i got any error, then it needs to redirected to a error file and in console. Also both error and output to be redirected to a log file. But i am facing the below error. #! /bin/sh errExit () { errMsg=`cat... (1 Reply)
Discussion started by: sarathy_a35
1 Replies

2. Web Development

How to log http 404 error to a separate log file?

Apache Web Server: how to log http 404 error to a separate log file and i do not want to log in access.log please advice. (2 Replies)
Discussion started by: raghur77
2 Replies

3. Shell Programming and Scripting

Need Script to ZIP/SAVE & then DELETE Log file & send a mail conformation for any error

ENVIROMENT Linux: RHEL 6.4 Log Path: /usr/iplanet/servers/https-company/logs Log Format: user.log.03-15-2015 I have log4j log rotation enabled rotating files on a daily basis. The rotated logs are NOT compressed & are taking up too much space. I need a script that will run daily that... (1 Reply)
Discussion started by: admin_job_admin
1 Replies

4. Solaris

Log error from cron job into log file

Hi Please would it be right to log the errors from a script running in cron in the following manner: /datax/vendor/dump.sh > /datax/vendor/err.log 2>&1 (16 Replies)
Discussion started by: fretagi
16 Replies

5. HP-UX

Script to monitor /var/opt/resmon/log/event.log file

AM in need of some plugin/script that can monitor HP-UX file "/var/opt/resmon/log/event.log" . Have written a scrip in sh shell that is working fine for syslog.log and mail.log as having standard format, have interrogated that to Nagios and is working as I required . But same script failed to... (3 Replies)
Discussion started by: Shirishlnx
3 Replies

6. Shell Programming and Scripting

Capture all error message in Log file and send the Log file by email

Hi I have a requirement to write a script to capture all errors in a Logfile and send the file in email. If there is any error occurred the subject of email will be ERROR , If there are no error occurred the subject of email will be SUCCESS. So I created a Log file and put the Appropriate... (2 Replies)
Discussion started by: dgmm
2 Replies

7. Shell Programming and Scripting

Appending error messages from log file next to the corresponding error record

Hi Everyone, I have an issue and trying to get a solution but was not succesful yet. Any help is greatly appreciated. I am using ksh to inoke sql loader to load data from txt file into two oracle tables based on the condition written in the control file. If an error occurs while loading into... (8 Replies)
Discussion started by: vpv0002
8 Replies

8. Shell Programming and Scripting

sqlplus error output to different error log file

HELLO, I am using such a command to write oracle sqlplus query result to text file: sqlplus -S xxx/xxx@xxxxxxx @\tmp\2.sql>\tmp\123.txt Is it possible to script that: If command succesfull write in \tmp\log.txt: timestamp and "succeded" and create 123.txt with results else If error... (2 Replies)
Discussion started by: tomasba
2 Replies

9. Shell Programming and Scripting

script for finding an error from a log file

Hi , I have a doubt about a shell script to find an ERROR from the log file. But I need to specify a the scan from a particular date and time in the log. Till now I have developed the following script. Please suggest what shall I add in this for date and time. If the script finds a particular... (5 Replies)
Discussion started by: himvat
5 Replies

10. UNIX for Advanced & Expert Users

Shell script to append a time for the existing error log file

Hi Guys, the requirement is like this, i am having a error log file in this format, 4594.493: parallel nursery GC 2594592K->2544691K (2969600K), 30.848 ms 4605.958: parallel nursery GC 2634887K->2584986K (2969600K), 38.900 ms 4619.079: parallel nursery GC 2822555K->2774812K... (12 Replies)
Discussion started by: gsprasanna
12 Replies
Login or Register to Ask a Question