getting help on finding exception in running log file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers getting help on finding exception in running log file
# 1  
Old 11-10-2008
Lightbulb 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 'JmsTimeOutException'`
if [ $count -ne 0 ]
then
echo "Error! $server is thrown JmsTimeOutException $(date +"%d-%b-%y at %X %Z")" > temp.txt
cat temp.txt | mail -s "Error! $server is thrown JmsTimeOutException $(date +"%d-%b-%y at %X %Z")" $mailid
rm temp.txt
fi

Now the problem is i need to check many exception and i want to mail that. I'm repeated the same code again and again in the script for every exception. i feel that i am following some wrong logic and trying tail the log again and again for each exception. Please suggest me some better think that i can use.

Thanks
Senthilkumar.
# 2  
Old 11-10-2008
you could put each pattern that you wish to search for in a file, one per line, and use grep -f option. -f is specified by posix, so should be available on most versions of grep.
Code:
count=`tail -n 1000 Trace.log | grep -c -f /home/user/patterns`

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Monitor logs for exception and if exception come then sent an email

Hi Folks, please advise , I have logs generated on unix machine at location /ops/opt/aaa/bvg.log , now sometimes there come exception in these logs also, so I want to write such a script such that it should continuously monitor these logs and whenever any exception comes that is it try to find... (3 Replies)
Discussion started by: tuntun27272727
3 Replies

2. Shell Programming and Scripting

Finding which is Running number

Hi All, I have a list of data in the listing file and I run row by row to process the record, but how to identify what is the current process line number ? Thanks. (2 Replies)
Discussion started by: ckwan
2 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. 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

7. 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

8. Programming

Exception Signal 11 while running JAVA code in UNIX

Hi, when i compile my java code in UNIX using javac, the class file is getting created. But when i try to run the code using java - classpath command, i get the following error. ---------------------------------------- /u/up11/sample/request:>java -classpath /u/up11/sample/request... (0 Replies)
Discussion started by: satish2712
0 Replies

9. UNIX and Linux Applications

Urgent---Program for getting Exception from a log

Hi Friends, I am new to Unix, Now I am Working with shell scripting in my company Description:-By executing that script I need to get the exception from the log file I need the program for getting the Exceptions from the logfile,,and that program should be generic...I mean if i want to... (5 Replies)
Discussion started by: Anji
5 Replies

10. UNIX for Advanced & Expert Users

finding a process running on a port

how do I find the process that is running on a port in HP-Unix? Murali (8 Replies)
Discussion started by: manduva
8 Replies
Login or Register to Ask a Question