LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 04-05-2012, 04:19 AM   #1
vaw
LQ Newbie
 
Registered: Feb 2012
Posts: 6

Rep: Reputation: Disabled
Want to get last 24 hours data from a log file


Hi,

I have a log file, which has data similar to :

[2011-11-11 00:33:53,962] xyz
[2011-11-21 01:28:01,269] abc
[2011-11-30 00:52:56,444] bcd

I want to be able to pull out data that is less than 24 hurs old from this file, so that on a daily basis i can get a report having data of last 24 hours.

Could you please let me know, using unix, how can i filter the data that i need ?
 
Old 04-05-2012, 09:37 AM   #2
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,592

Rep: Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559Reputation: 2559
Quote:
Originally Posted by vaw View Post
Hi,
I have a log file, which has data similar to :

[2011-11-11 00:33:53,962] xyz
[2011-11-21 01:28:01,269] abc
[2011-11-30 00:52:56,444] bcd

I want to be able to pull out data that is less than 24 hurs old from this file, so that on a daily basis i can get a report having data of last 24 hours.
Could you please let me know, using unix, how can i filter the data that i need ?
Similar question to your other thread, where someone even wrote you a script to do something similar. Have you tried to modify that? You can also just use grep to look for whatever string you want, and save those results into another file.

You can also use logrotate, and have it set to archive log files every day, so that your logs will only EVER have 24 hours of data in them, going back as far as you'd like. Read the man pages on grep and logrotate.
 
  


Reply

Tags
date, filter, logs, sort


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
need a script to continuously monitor appended data to a log file akitty Programming 5 10-14-2010 02:39 AM
In Apache server, How to change log file location and log format for access log fil? since1993 Linux - Server 1 08-19-2009 04:14 PM
How do I interpret the log data from a harddrive's S.M.A.R.T log? mysteron Linux - Hardware 2 09-29-2008 06:45 AM
my /var/log/syslog only logs the last 12 hours or so ALInux Linux - General 4 02-11-2006 10:53 AM
how to log data to disk file mikesievers Programming 1 04-25-2002 12:36 PM


All times are GMT -5. The time now is 03:42 PM.

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 Google+: linuxquestions
Open Source Consulting | Domain Registration