LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 11-02-2012, 12:20 AM   #1
radhika_s
LQ Newbie
 
Registered: Aug 2011
Posts: 2

Rep: Reputation: Disabled
viewing logs


Hi,

I'm connecting linux server through putty. I want to view few logs that were created yesterday in the log file. Since im using through putty i'm unable to view the exact log that was created by yesterday. I tried using head and tail command but as there are many lines in log files im unable to view the file that were created by yesterday. Could you please help me to view that file.
 
Old 11-02-2012, 12:54 AM   #2
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 247

Rep: Reputation: 106Reputation: 106
Hi there, and welcome to the forums.

Your request is a little sketchy on details. Which log file(s) specifically are you referring to?

Before we look at how to find messages for a particular date, remember that many (most?) log files on Linux are probably rotated regularly, typically when they reach a specific size. This means all the messages for a particular date may not be in a single file; they may be spread across 2 or more files. On my one machine for example the main /var/log/messages log file rotates every 2-3 days, and did so yesterday, so the messages for yesterday are spread across /var/log/messages-20121101.bz2 (the last archived & compressed file) and /var/log/messages (the current file).

Assuming the log files in question are written by the syslog deamon, each message should contain a date & time stamp. The actual format of the date may vary depending on your distro & localle, so check the file for examples. On my machine I can find yesterday's messages in the current log by running:
Code:
grep '^Nov  1' /var/log/messages | less
I can do the same for the previous (archived) file with:
Code:
zgrep '^Nov  1' /var/log/messages-20121101.bz2 | less
or combine the two with:
Code:
(bunzip2 -c /var/log/messages-20121101.bz2 ; cat /var/log/messages ) | grep '^Nov  1'| less
I hope this helps. Good luck!
 
  


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
Viewing FTP logs dcjones Linux - Newbie 1 11-13-2011 02:12 PM
Viewing logs when they're scrambled looking.. mike2010 Linux - Newbie 11 01-19-2010 05:17 PM
Viewing System Logs from Root ispguy_01 Linux - General 2 06-23-2007 04:03 PM
web interface for viewing logs clau_bolson Linux - Software 5 02-03-2004 07:19 AM
Computer Crashing - Viewing logs Jose Muņiz Linux - General 4 01-03-2004 06:54 PM


All times are GMT -5. The time now is 05:17 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