grep active log file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting grep active log file
# 1  
Old 06-29-2009
Data grep active log file

Hi Gurus,

I am facing a problem with grepping a set of data in active log file which are the info not in uniform, below is the sample data information.
I am trying to grep value.

  • Connect_PM Connect to APPS gateway failed
  • ERROR connection to host anyserver.com, service 6600 timed out
  • ERROR connection to partner broken
the problem that i facing now is, the set of info are active and not uniform, to make a reference, i am thinking to grepping the last update "TIMESET" and follow by the line of the row of information, how do i perform it using shell? Thanks


Code:
>TIMESET> Tue Jul 15 05:25:49 2008
T:6 ======> Connect to APPS gateway failed
Connect_PM  DEST=TAH, GWHOST=anyserver.com, GWSERV=anyNameSrvr, ASHOST=anyserver.com, SYSNR=00

LOCATION    CPIC (TCP/IP) on local host with Unicode
ERROR       connection to host anyserver.com, service 6600 timed
            out

TIME        Tue Jul 15 05:25:49 2008
RELEASE     640
COMPONENT   NI (network interface)
VERSION     37
RC          -12
MODULE      nixxi_r_mt.cpp
LINE        1067
DETAIL      NiPConnect
COUNTER     46

# 2  
Old 06-30-2009
I don't understand what you are trying to achieve. What is your desired output?
# 3  
Old 06-30-2009
Maybe my question are not clear, sorry for that.
My desire output are like below:

And it should content the current error from the log files.
Output:-
Code:
>
Tue Jul 15 05:25:49 2008 ERROR connection to host anyserver.com, service 6600 timed out

# 4  
Old 07-01-2009
Still I am not very clear about the requirement.
Also, I could not see the third error message "ERROR connection to partner broken" in your logs.

as par my assumption, if you want to grep on the basis of "TIMESET" then one alternative could be "To grep the lines till your Error message".

Code:
grep -A5 ">TIMESET> Tue Jul 15 05:25:49 2008"

will show you the next five lines just after the "TIMESET".


if you want to achieve something else, please let us know clearly.

Last edited by clx; 07-02-2009 at 03:06 AM.. Reason: typo
# 5  
Old 07-01-2009
Hrm, you could use awk or perl:
Code:
awk '/^>TIMESET>/ { $1=""; ts=$0; error=1 } error && /^ERROR/ { print ts,$0; error=0; }'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep a log file starting from a specific time to the end of file

I have a log file which have a date and time at the start of every line. I need to search the log file starting from a specific time to the end of file. For example: Starting point: July 29 2018 21:00:00 End point : end of file My concern is what if the pattern of `July 29 2018 21:00:00`... (3 Replies)
Discussion started by: erin00
3 Replies

2. UNIX for Advanced & Expert Users

Copy open active log

Hi, I try to copy the nohup.out to new file using cp command on solaris 10 However, the new file is very large size compare to nohup.out The file is in English format text. Any solution for copying active/open log file without problem with the size. ex: /dir > du -sh nohup.out 636K ... (7 Replies)
Discussion started by: xitrum
7 Replies

3. Shell Programming and Scripting

Search the string in the active log and send mail

Hello, I wanted to search specific string in the acitve log file and send an email if the search string found in the log. Log file is written by application all the time. So, script has to search if any new log entry has the specific string for example " sample exception" and send an email. (1 Reply)
Discussion started by: balareddy
1 Replies

4. Shell Programming and Scripting

How to grep a log file for words listed in separate text file?

Hello, I want to grep a log ("server.log") for words in a separate file ("white-list.txt") and generate a separate log file containing each line that uses a word from the "white-list.txt" file. Putting that in bullet points: Search through "server.log" for lines that contain any word... (15 Replies)
Discussion started by: nbsparks
15 Replies

5. Shell Programming and Scripting

How do I calculate total number of active and non active hosts?

#!/bin/bash for digit in $(seq 1 10) do if ping -c1 -w2 192.168.1.$digit &> /dev/null then echo "192.168.1.$digit is UP" else echo "192.168.1.$digit is DOWN" fi done (3 Replies)
Discussion started by: fusetrips
3 Replies

6. Shell Programming and Scripting

Shell Script to grep Job File name and Log File name from crontab -l

Hello, I am new to shell scripting. I need to write a shell script where i can grep the name of file ie. .sh file and log file from crontab -l. #51 18 * * * /home/oracle/refresh/refresh_ug634.sh > /home/oracle/refresh/refresh_ug634.sh.log 2>&1 #40 17 * * * /home/oracle/refresh/refresh_ux634.sh... (1 Reply)
Discussion started by: guptra
1 Replies

7. Shell Programming and Scripting

Loop script required within an active log file

I need some help please... This is the scenario what I am sitting with. 1 - I am kicking of a batch script. 2 - This batch script is writing to an active log file which is also use by other batch scripts. 3 - I need to monitor this active log file and grep for the script name as well as the... (3 Replies)
Discussion started by: Henk Trumpie
3 Replies

8. Solaris

Link based Active Active IPMP

Hi, I need to configure 4 ip address (same subnet and mask) in one ipmp group (two interfaces) in an active active formation (link based). Can some one provide the steps or a tutorial link. Thanks (2 Replies)
Discussion started by: Mack1982
2 Replies

9. UNIX for Advanced & Expert Users

Rollover/compress log from ACTIVE process

I have some Solaris processes that run weeks at a time that create rather large log files that I would like to archive/compress daily. Instead of stopping the process, what can be done so that the log file is backed up and shrunk, but the process can still log to the open file handle without major... (7 Replies)
Discussion started by: ckmehta
7 Replies

10. AIX

Question about HACMP for active-active mode

Hi all, I am new to HACMP. So sorry for the newie question. But I did search the forum and it seems that no one asks this before. So if a 2-node cluster runs in active-active mode (and the same application), what is the benefit of using HACMP ? If it runs in active-stanby, it is easy to... (9 Replies)
Discussion started by: qiulang
9 Replies
Login or Register to Ask a Question