Grep Logs That Are Updating | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Grep Logs That Are Updating

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-18-2013
Carl2013 Carl2013 is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 30 January 2013, 4:08 PM EST
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Grep Logs That Are Updating

Hello all. I am new to this forum and also very new to using grep - so please excuse me if this question is not in the correct forum and/or is not pertinent to this website.

I use greps like this:


Code:
gunzip -c L:\System1\SailLogger_20071019* L:\System2\SailLogger_20071019* L:\System3\SailLogger_20071019* | grep 35=Order

These logs are updating continuosly throughout the day. SailLogger_20071019* is the name of log followed by YYYYMMDD. I use the wildcard to target all the logs (the logs themselves are renamed at the top of each hour - eg 2007101907 (for 7am) and 2007101908 (for 9am).

When I run this grep, it will only extract from the first log in the statement - System1. I then get an error message related to not being able to find the end of the file.

Is there a way to grep all these logs ?

Thanks you for any help and guidance.

Regards.

Moderator's Comments:
edit by bakunin: Please use CODE-tags. It is in the rules you should have read. We even have this code tag video for how to use code tags when posting code and data.

Last edited by bakunin; 01-30-2013 at 10:40 AM..
Sponsored Links
    #2  
Old 01-18-2013
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 1 September 2014, 10:35 PM EDT
Location: Saskatchewan
Posts: 19,272
Thanks: 774
Thanked 3,237 Times in 3,035 Posts
It is very strange and unusual for a gzipped log to be continually appended to. Are you sure all of these logs are already compressed?
Sponsored Links
    #3  
Old 01-18-2013
Carl2013 Carl2013 is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 30 January 2013, 4:08 PM EST
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Hi Thanks for replying. Yes these logs are updating every 30 seconds. I tried this grep -

gunzip -c L:\System1\SailLogger_20130118* L:\System2\SailLogger_20130118* L:\System3\S
ailLogger_20130118* | grep 35=SailErrorNotice

and got results for System1 logs but then received this message -


gunzip: L:\System1\SailLogger_2013011813.tlg.gz: unexpected end of file

And in case it matters, I am running these greps in a windows environment.
    #4  
Old 01-18-2013
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 1 September 2014, 10:35 PM EDT
Location: Saskatchewan
Posts: 19,272
Thanks: 774
Thanked 3,237 Times in 3,035 Posts
I just noticed that you're unzipping the same thing three times in a row:


Code:
L:\System1\SailLogger_20130118*
L:\System2\SailLogger_20130118*
L:\System3\SailLogger_20130118*

Is that really intentional? Didn't you want three different logfiles?
Sponsored Links
    #5  
Old 01-18-2013
Carl2013 Carl2013 is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 30 January 2013, 4:08 PM EST
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Hi. Yes. Each path has a differnt log (System1,2,3) that follows the same naming convention.
Sponsored Links
    #6  
Old 01-18-2013
RudiC RudiC is offline Forum Advisor  
Registered User
 
Join Date: Jul 2012
Last Activity: 1 September 2014, 3:01 PM EDT
Location: Aachen, Germany
Posts: 4,159
Thanks: 69
Thanked 995 Times in 943 Posts
Do you know about the zgrep command (cf. man zgrep):
Quote:
NAME
zgrep - search possibly compressed files for a regular expression
Sponsored Links
    #7  
Old 01-18-2013
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 1 September 2014, 10:35 PM EDT
Location: Saskatchewan
Posts: 19,272
Thanks: 774
Thanked 3,237 Times in 3,035 Posts
Pardon my blind eyes, I don't know how I missed that.

Anyway. If this code is for a real shell and not windows cmd, I'd try this:


Code:
for FILE in L:\System1\SailLogger_20130118* L:\System2\SailLogger_20130118* L:\System3\SailLogger_20130118*
do
        gunzip < "$FILE"
done | grep 35=SailErrorNotice

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to check whether logs are updating or not? mail2sant Shell Programming and Scripting 1 11-30-2009 12:46 AM
how to grep the logs for two particular timestamp jacktolearn Shell Programming and Scripting 1 04-18-2009 09:31 PM
Grep yesterday logs from weblogic logs harish.parker Shell Programming and Scripting 3 11-04-2008 08:00 AM
Grep logs on the fly harperonline Shell Programming and Scripting 3 05-12-2008 09:32 PM
Constantly updating log files (tail -f? grep? awk?) nortonloaf UNIX for Dummies Questions & Answers 0 12-03-2006 10:20 PM



All times are GMT -4. The time now is 05:06 AM.