LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 03-20-2007, 10:28 AM   #1
graziano1968
Member
 
Registered: Sep 2004
Posts: 212

Rep: Reputation: 30
how to cat a log starting FROM a date TO a date


Hello

I have a maillog like this

Mar-15-07 07:49:58 82.235.17.23 <ltcrosby@mailreader.com>..blah
Mar-15-07 07:52:50 82.235.17.23 <ltcrosby@mailreader.com>..blah
...
Mar-20-07 01:52:50 82.235.17.23 <ltcrosby@mailreader.com>..blah

Suppose I wish to "cat" grep or tail (from command line) only
lines from Mar-15-07 07:49:58 to (Mar-15-07 07:49:58)+28 hours.
How can I do that ?

Suppose I want seach the value "delayed rejected" in the interval
Mar-15-07 07:49:58 to (Mar-15-07 07:49:58)+28 hours .

How can I do this search from command line ?

Thanks


(I need this to check email rejected from my greylisting filter in 28 hours.)

Thanks

Last edited by graziano1968; 03-20-2007 at 10:32 AM.
 
Old 03-20-2007, 05:26 PM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,500

Rep: Reputation: 285Reputation: 285Reputation: 285
You can do something like this, making it as specific as you want:

Code:
grep -e "^Mar 1[56] " /var/log/maillog* | grep "delayed rejected" | less
 
Old 03-20-2007, 07:24 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 10,447

Rep: Reputation: 622Reputation: 622Reputation: 622Reputation: 622Reputation: 622Reputation: 622
Use sed - search over the last few days, there was a thread that covered this almost exactly.
 
Old 03-21-2007, 06:14 AM   #4
graziano1968
Member
 
Registered: Sep 2004
Posts: 212

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by syg00
Use sed - search over the last few days, there was a thread that covered this almost exactly.

I am searching the post but I cannot find it

I am really lost using sed .
Suppose I want sed from Mar-15-07 07:52:50 to Mar-16-07 07:52:50
for "delayed" , how to do that please ?

Thanks
 
Old 03-21-2007, 06:34 AM   #5
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 51
Code:
sed -n -e '/Mar-15/,/Mar-16/p' /var/log/maillog | grep delayed
It's possible to do it only with sed but I don't manage...

http://sed.sourceforge.net/

edit:

okay I found it, it's another form:

Code:
sed -n -e '/Mar-15/,/Mar-16/ {/delayed/p}' /var/log/maillog

Last edited by nx5000; 03-21-2007 at 06:45 AM.
 
Old 03-21-2007, 07:51 AM   #6
fooks
Member
 
Registered: Jan 2007
Location: Ukraine
Posts: 47

Rep: Reputation: 15
cool, this is exactly i was looking also !
thnx a lot
 
Old 03-21-2007, 08:27 AM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 10,447

Rep: Reputation: 622Reputation: 622Reputation: 622Reputation: 622Reputation: 622Reputation: 622
Yeah, thanks nx5000 - must admit I am happy to pipe through grep. I find it easier to remember to syntax.
Lots of good people with good ideas happy to contribute here on LQ.
 
Old 03-21-2007, 08:49 AM   #8
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 51
Quote:
Originally Posted by syg00
Yeah, thanks nx5000 - must admit I am happy to pipe through grep. I find it easier to remember to syntax.
Lots of good people with good ideas happy to contribute here on LQ.
I discover things while helping people and then I can just bookmark to my own threads.
LQ is my second hard disk
Thanks Jeremy
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the correct syntax order for tar with --after-date DATE, --newer DAT farhan Linux - General 1 03-16-2007 08:43 AM
thunderbird puts time instead of date under 'date' header wabbalee Linux - Software 4 11-26-2006 04:58 AM
Date in Log file name Runningonair Linux - General 8 06-02-2006 09:45 AM
CAT and DATE Rv5 Programming 3 09-11-2004 05:24 PM
lastlog date does not match system date? jcmj Linux - Networking 6 10-22-2002 12:09 PM


All times are GMT -5. The time now is 03:34 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration