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.
/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" email@example.com
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