It would be really nice if logrotate had a way to send
mail with the log file that was just rotated, instead
of only the one that's about to be removed from the end
of the rotation.
E.g., I've got a setup where I keep 31 days of logs,
rotated daily. I'd like to get mail each night with
the previous day's logs, instead of the logs from a
I've chatted with Erik about this via e-mail briefly,
and I plan on fetching the source for logrotate and
creating and submitting a patch...
I have an initial pass at a patch.
It seems to work both with and without compression enabled
and with either the 'mailfirst' or 'maillast' option (that's
how I chose to mark it -- this could of course be changed).
I do notice one problem with it, though, and that is that the
mail gets sent before the log file is rotated, which in the
case of mailfirst, means that we actually end up mailing the
active file. I suspect the whole mail routine should be moved
to after the rotation of the main file, and probably even after
the postrotate scripts have run, but before the removal of the
last file happens. However, I'm going to leave that for someone
else to do (maybe I'll do it some day in the future), as I'm not
real familiar with this code, and I don't want to take the time
right now to figure out the intracacies of any inter-dependancies
that might exist in order-of-execution of these various commands.
While I was at it, I fixed a typo in the man page (that was
referenced in semi-related bug #1932
Here are the patches:
Note that the above also includes changes to remove end-of-line
whitespace (a pet peeve of mine). If you want the diffs without
that, they are available too, here:
Oh, I forgot to mention, the changes that I made were against the
code that I found as 'logrotate-2.5.tar.gz' in the ftp archive.