LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-21-2009, 07:49 PM   #1
rajeshkahara
LQ Newbie
 
Registered: Nov 2003
Distribution: red hat
Posts: 18

Rep: Reputation: 1
Wink log file tricks - searching / digging


hi,

was looking for some commands to quickly dig log files. like -

1. how to extract logs from specific time duration - say, last 4th to 5th hour.
2. count the number of entries in a standard format log file, giving totals for the day/hour combination.

something like these kindof tipsntricks. infact, these are intv questions , Will be great if someone can point to links.

Thanks in advance.

-Rajesh.
 
Old 08-22-2009, 04:17 PM   #2
hasienda
Member
 
Registered: May 2009
Location: Saxony, Germany
Distribution: Debian/GNU Linux
Posts: 37

Rep: Reputation: 18
Post

Quote:
Originally Posted by rajeshkahara View Post
hi,

was looking for some commands to quickly dig log files. like -

1. how to extract logs from specific time duration - say, last 4th to 5th hour.
2. count the number of entries in a standard format log file, giving totals for the day/hour combination.
Let's start easy: What is a standard log file (format) to you? You might simply be more specific about what challenge you're facing (give a small quote out of the log file(s) in question.

If it's something like syslogs output
Quote:
Aug 22 21:53:01 gnome /USR/SBIN/CRON[20258]: (mail) CMD ( if [ -x /usr/lib/exim/exim3 -a -f /etc/exim/exim.conf ]; then /usr/lib/exim/exim3 -q ; fi)
Aug 22 22:00:34 gnome ntpd[3983]: kernel time sync status change 0001
Aug 22 22:08:01 gnome /USR/SBIN/CRON[20795]: (mail) CMD ( if [ -x /usr/lib/exim/exim3 -a -f /etc/exim/exim.conf ]; then /usr/lib/exim/exim3 -q ; fi)
you could do a simple
Code:
$> cat /<path-to-logfile>/logfile | grep "Aug 22 21" | wc -l
and you're done (getting the number of matching lines for the selected hour 21:00-21:59 in the example). I all boils down to finding a suitable search string to use with the grep command. Hope that help a little. Please respond with some more details, if not.

Greetings and good luck.
 
Old 08-22-2009, 04:32 PM   #3
tulsi
Member
 
Registered: Aug 2009
Location: Chennai
Posts: 54

Rep: Reputation: 15
tail -f /var/log/messages
is a recently load a logfiles.
 
  


Reply



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
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
setting file permissions for file /var/log/Xorg.0.log mfb Linux - Security 1 07-07-2009 01:41 PM
New Tricks and Toys For Linux Addicts- USB tricks and Portables OS's! linus72 Linux - Newbie 3 05-29-2009 05:36 PM
searching log files in linux ramanika Linux - Newbie 2 10-21-2008 11:56 AM
file editing tricks abhishekfishy Programming 2 08-09-2007 02:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:59 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration