Re: emailing log files

From: Dan Shauver <shauver@dont-contact.us>
Date: Wed, 14 Jun 2000 08:28:36 +1200

> How about adding an entry to the crontab, something like:
>
> 0 0 * * * more /usr/local/squid/logs/access.log | mail user@domain.com
>
> Andre

I'd do this:

59 11 * * * /usr/bin/Mail -s squidlog user@domain.name < /path/to/access.log

Setting it to midnight would ensure that the access log for that day got
sent along, as the logs get rotated just after midnight. Using Mail
in this fashion allows you to specify the subject line, and doesn't
require any other utilities (like cat or more). While there shouldn't be
any problems using more or cat with a pipe to mail, there's no real
reason to do so.

Someone else, however, did make an good point in mentioning using gzip
to compress the file before sending it. If you're seeing a lot of
traffic, the file could get quite large. If that's the case, I'd
suggest writing a small shell script to make a copy of access.log,
gzip it, and mail it off.

Dan Shauver
HortResearch UNIX SysAd
Received on Tue Jun 13 2000 - 14:33:44 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:54:01 MST