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

by Jon | 1 comment | Tags: administration, logs, mail, shell script, webserver


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

Happy Hour by Candy
Guys - $12
Girls - $12

Apparel

Search Amazon

Search Amazon.com
Search Amazon.co.uk

Advert

Web hosting by ICDSoft