LinuxQuestions.org
Help answer threads with 0 replies.
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
 
Search this Thread
Old 03-30-2010, 10:54 AM   #1
rogerdv
Member
 
Registered: Jul 2005
Location: Cuba
Distribution: redhat
Posts: 52

Rep: Reputation: 15
isolating a day logs from a squid week log


I have been requested to deliver the logs for last friday, but the problem is that I have configured squid logs to be weekly, not daily. How can I extract the logs generated friday from the week file?
 
Old 03-30-2010, 10:59 AM   #2
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Does every log entry begin with some common string, perhaps including the date of the entry? Logs usually are of this nature. If this is the case, my choice would be to use grep or awk on the logfile of the week in question; grep for all entries containing the desired date of the Friday you want, and redirect that output to a fresh file for delivery.

Sasha

Last edited by GrapefruiTgirl; 03-30-2010 at 11:01 AM. Reason: added awk as an alternative
 
Old 03-30-2010, 11:21 AM   #3
rogerdv
Member
 
Registered: Jul 2005
Location: Cuba
Distribution: redhat
Posts: 52

Original Poster
Rep: Reputation: 15
Yes, but squid logs date in an special format that requires decoding. Solved the problem now using sarg, but I was curious I could send the raw log to avoid stupid requests like this next time.
 
Old 03-30-2010, 11:36 AM   #4
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
The logs are dated in UNIX-time format by default. You'd need to either involve the `date` command to convert to a 'regular' date format and narrow down which entries are from the date in question, or perhaps easier would be use one of the many tools and scripts I can see on the internet, for examining squid logs and/or converting them to a standard (e.g. httpd) log format, and then isolate the days you want.

More often than is probably healthy, I tend to do things in possibly the less-easy way, so if I were in the situation you describe, I might be inclined to scan the file line by line with a script, converting the date of each line, and then grabbing out the lines whose dates correspond to the day in question, and dumping them into a new file..

If you want an example code of how I might do this, post a few lines of the log in question and sometime later I'll show you what I mean. But meanwhile, it's quite possible that someone who is familiar with squid-logs and does this sort of thing regularly, will offer a 'commonly used' alternative to what I propose.

Sasha
 
  


Reply

Tags
log, squid


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cron job: day of month / day of week conflict? geekpie Linux - General 2 10-21-2009 03:56 AM
Squid and FTP logs to Centralised Log server sakthi.s Linux - Server 8 07-23-2008 08:57 AM
Findin The Day Of The Week D-KNUCKLES Linux - General 1 10-21-2007 11:46 AM
Opennms Logs - where are web.log, web_rtc.log and webauth.log referenced? not_much_of_a_guru Linux - Networking 0 07-12-2006 10:28 AM
Schedule by day of the week stand Linux - General 1 08-30-2004 11:49 PM


All times are GMT -5. The time now is 11:13 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 Google+: linuxquestions
Open Source Consulting | Domain Registration