Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.

Bug 2103

Summary: RFE: logrotate needs a way to mail recent log, not just oldest
Product: [Retired] Red Hat Linux Reporter: redhat-bug-fixer
Component: logrotateAssignee: Erik Troan <ewt>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.1   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 1999-06-16 20:49:17 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description redhat-bug-fixer 1999-04-10 01:03:18 UTC
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
month ago.

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

Comment 1 redhat-bug-fixer 1999-04-10 02:46:59 UTC
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:

Comment 2 redhat-bug-fixer 1999-04-10 02:47:59 UTC
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.