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 | /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

Be Sociable, Share!

by | 1 comment | Posted in administration, logs, mail, shell script, webserver | Link to this


  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

Show who you are with a Gravatar.


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

Staples Logo

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


Search Amazon

Search Amazon.com
Search Amazon.co.uk

Recent Forum Topics


    Web hosting by ICDSoft