15 January 2007 @ 14:33Email that log to me

At one point I decided to have the web server email the day’s access_log to me. Instead of emailing the entire log, I grep’ed through the log to only get “today”, piped that to grep again to exclude entries that contained the IP address of the Intermapper server, and then piped that to mail. So, everyday I have the previous day’s log waiting in my inbox.

#! /bin/sh

today=`date +%d/%b/%Y`

/usr/bin/grep "$today" /var/log/httpd/access_log | /usr/bin/grep -v 192.168.1.70 | /usr/bin/mail -s "access_log for $today" me@email.net
exit 0

I save this shell script and schedule it with cron to run ever day right before midnight.

59 23 * * * /bin/sh /Library/Scripts/mail_log.sh

Share this:
  • E-mail this story to a friend!
  • Print this article!
  • Wists
  • del.icio.us
  • Reddit
  • Digg
  • StumbleUpon
  • Slashdot
  • Technorati
  • SphereIt
  • Sphinn
  • Google
  • Facebook
  • NewsVine
  • Furl
  • YahooMyWeb
  • Pownce
  • TwitThis
  • Shop Apple
  • Shop Dell

 

Related posts

by Jon | Posted in administration, logs, mail, shell script, webserver

Link to this post

HTML
BBCode

Comments:

  1. Command Line Warriors | 11 Jul 2007 @ 20:10 #

    This Week on the Command Line: Lieutenant Worf’s favourite distro is?…

    I was at the LugradioLive 2007 conference this last weekend which was fab, see here for my take on it.
    I am famous, well no, but at the end of the JakAttack podcast 55 [ogg | mp3], they read out my email, rock on!
    This post is another of my occasional…

Add a Comment

 

Sign up for PayPal and start accepting credit card payments instantly.

Get fed!

rss icon subscribe to Geek stuff

rss icon Geek stuff in your inbox

Add the "Geek stuff" Google Gadget to your homepage

Add the "Daily Deals" Google Gadget to your homepage

Featured Tee

UneeTee.com

One Day, One Artist, One cool T-shirt

Overgrown by Jack
Guys - $12
Girls - $12

Apparel

Search Amazon

Search Amazon.com
Search Amazon.co.uk

Advert

Web hosting by ICDSoft