Register
It is currently Thu Apr 24, 2014 8:00 am

grab apaches 404 errors for the day


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Sun Apr 04, 2010 7:37 pm   

Joined: Sun Apr 04, 2010 7:19 pm
Posts: 1
let me preface this by saying i am very new to bash scripting

basically looking for a script to yank out the 404 errors from multiple access logs and write them to a seperate file... i am hosting a ton of sites and would like one report that shows me all the days 404 errors server wide.

been trying to build around:
Code:
cat foo.com-access_log | grep  ' 404 ' | grep '31/Mar/2010'


i need the date to be today's date in the format that Apache uses... Thank you in advance for the help...


Top
 Profile  
 PostPosted: Sun Apr 04, 2010 8:24 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 512
Hi huggy77,

I'd rather use a sed expression:
Code:
sed -n "\@$(LC_TIME=C date +'%d/%b/%Y')@{/ 404 /p}" foo.com-access_log


Top
 Profile  
 PostPosted: Sun Apr 04, 2010 8:55 pm   

Joined: Sat Apr 03, 2010 1:47 pm
Posts: 6
Personally, I avoid using "cat filename | grep 'something' " when "grep 'something' /path/to/filename" works just the same.
With that said, I would advise using the following syntax:

Code:
grep "404" foo.com-access_log | grep "`date +%d/%b/%Y`"


I hope that helps you out.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP