script for finding an error from a log file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script for finding an error from a log file
# 1  
Old 11-17-2008
Bug 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 error it should throw 1 or else 0.


#!/bin/sh
# Script to find the error in the log file
ERROR="SCHD0061E"
read ERROR
if [ $ERROR="SCHD0061E" ] ;then
echo "1";
else echo "0"
fi

Kindly suggest what else is missing from this script. And how to specify the path for the log file .

Thanks & Regards


Last edited by himvat; 11-17-2008 at 03:25 PM..
# 2  
Old 11-17-2008
Post a sample log file
# 3  
Old 11-17-2008
Kindly have a look at the sample of the log and suggest

Regards

Last edited by himvat; 11-17-2008 at 03:23 PM..
# 4  
Old 11-17-2008
Computer

Just have a look at below code. I assume that the Errors are logged in log.txt

grep -w "ERROR" log.txt | cut -d" " -f1,2,3 > ErrLog.txt

if [ -s ErrLog.txt ]
then
echo "Has Errors"
else
echo "No Errors"
fi
# 5  
Old 11-17-2008
Question

You posted the error file as a Word document. Is it truly a Word document?
Can you simply cut/paste a section of the log into your response. Make sure to use th Code Tag. [Highlight the section of your message, then press the # icon button -- this will maintain formatting and spacing.]

Finally, if I understand you request, you are try to search from a particular data & time forward only. Please verify on this.
# 6  
Old 11-17-2008
yes I need to develop a script that will look for an error only in the current date logs and will throw an alert mail to the mail ID

thanks

Last edited by himvat; 11-17-2008 at 03:23 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding file extension on C Shell script

I very new to C Shell. I am trying to do is read from Command line. Find the if the file is zip, .txt, symbloic link,pipe, unknow (if file is not zip, txt, sy....) here is what I what got so far. I am very stuck atm Please help me out : If the file is symblooc link what file is link to ... (12 Replies)
Discussion started by: madbull41
12 Replies

2. Shell Programming and Scripting

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... (1 Reply)
Discussion started by: cougartrace
1 Replies

3. Shell Programming and Scripting

Finding errors in log file only in last 10 minutes

Hi there, I have a log file that I need to check every 10 minutes to find if a specific error exists but only in that 10 minute period. The reason is that the log is quite large, and will frequently contain these errors, so I only want alerting if it in the last 10 minutes - I don't want... (3 Replies)
Discussion started by: paul_vf
3 Replies

4. Shell Programming and Scripting

Help finding info from log file

Hi, I have a log file that contains information such as this: date id number command1 command2 command3 command4 data data data date id number command1 command2 command3 command4 (4 Replies)
Discussion started by: bbbngowc
4 Replies

5. Red Hat

Need help with a shell script for finding a certain pattern from log file

Hell Guys, Being a newbie, I need some help in finding a certain string from a log file of thousands of lines (around 30K lines) and have the output in a separate file. Below is the file output - 10.155.65.5 - - "POST... (15 Replies)
Discussion started by: rockf1bull
15 Replies

6. AIX

Finding name of script file that signaled my process

Is there a way to find out the path/name of a script file that signaled my process? All that shows up from the signal info data is ksh. Even in getprocs64 is is just ksh. I am not sure why the full path and file name are not showing up instead of the shell name. I tried ptrace64 with PT_LDINFO but... (4 Replies)
Discussion started by: soccertl
4 Replies

7. Shell Programming and Scripting

Need help with finding unique string in log file

Shell script help Here is 3 sample lines from a log file <date> INFO <java.com.blah> abcd:ID= user login <date> DEBUG <java.com.blah> <nlah bla> abcd:ID=123 user login <date> INFO <java.com.blah> abcd:ID=3243 user login I want to find unique "ID" from this log... (3 Replies)
Discussion started by: gubbu
3 Replies

8. UNIX for Dummies Questions & Answers

getting help on finding exception in running log file

Hi all, I am trying to write a script for an application server log file where i want to put this script as a cron tab entry and it will check the server log file last 1000/500 line for every fifteen minute. i am using the script like this. count=`tail -n 1000 Trace.log | grep -c... (1 Reply)
Discussion started by: senthilkumar_ak
1 Replies

9. Shell Programming and Scripting

awk script required for finding records in 1 file with corresponding another file.

Hi, I have a .txt file (uniqfields.txt) with 3 fields separated by " | " (pipe symbol). This file contains unique values with respect to all these 3 fields taken together. There are about 40,000 SORTED records (rows) in this file. Sample records are given below. 1TVAO|OVEPT|VO... (2 Replies)
Discussion started by: RRVARMA
2 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