Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Red Hat This forum is for the discussion of Red Hat Linux.


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

Rep: Reputation: Disabled
viewing logs


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, 01:54 AM   #2
Registered: Jan 2012
Location: South Africa
Posts: 500

Rep: Reputation: 189Reputation: 189
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:
grep '^Nov  1' /var/log/messages | less
I can do the same for the previous (archived) file with:
zgrep '^Nov  1' /var/log/messages-20121101.bz2 | less
or combine the two with:
(bunzip2 -c /var/log/messages-20121101.bz2 ; cat /var/log/messages ) | grep '^Nov  1'| less
I hope this helps. Good luck!


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

All times are GMT -5. The time now is 06:57 PM.

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