Bug 173088 - Add "minsize" directive
Add "minsize" directive
Product: Fedora
Classification: Fedora
Component: logrotate (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Peter Vrabec
: FutureFeature
Depends On:
  Show dependency treegraph
Reported: 2005-11-13 18:44 EST by Glenn Zazulia
Modified: 2007-11-30 17:11 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2006-05-17 11:52:25 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Patch to add 'minsize' directive (3.63 KB, patch)
2005-11-21 01:38 EST, Glenn Zazulia
no flags Details | Diff
patch adjusted to logrotate 3.7.3 (2.34 KB, text/x-diff)
2006-05-09 08:07 EDT, Peter Vrabec
no flags Details
Suggested logrotate man page addition for minsize (1.31 KB, patch)
2006-05-16 18:32 EDT, Glenn Zazulia
no flags Details | Diff

  None (edit)
Description Glenn Zazulia 2005-11-13 18:44:24 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.0.7-1.1.fc4 Firefox/1.0.7

Description of problem:
Sometimes it is desireable to configure logrotate to rotate a log file *both* with a temporal directive and a size directive together.  One may want log files to be rotated weekly but only after the log file has grown beyond a certain amount.  Alternatively (and equivalently), one may want log files to be rotated after they reach a certain size but not before a certain amount of time has passed.

For example, I would like my mail logs to be rotated after they reach 100KB in size and a week has passed since the last rotation (and I would like to have 4 weeks of logs).  Currently, I can only specify one or the other.  If I specify a 'size' directive of 100k and a 'rotate' directive of 4 and my mail server is active, I might end up with just 4 days of mail logs total, since each day the mail log may reach 100KB.  The alternative problem is if I specify a 'weekly' directive and the mail server is sporadically inactive, then after four weeks, if there might be no activity at all for a few weeks, I could end up with no log records at all and a bunch of zero-length log files.

The solution is to add a 'minsize' directive that functions exactly like the 'size' directive but that wouldn't be a mutually exclusive option with the temporal directives (e.g., 'weekly').  I have already implemented this enhancement and have been using it in production for the past few years.  I recently patched the last released version and after a few more days of testing, I will attach the proposed solution to this enhancement request as a patch file.

BTW, I went with a new directive instead of just making the existing 'size' directive work with the temporal directives (ie. by removing the mutual exclusive behavior) because both behaviors may be desireable to different users.  Some will be accustomed to (and prefer) the existing behavior, where one might specify a default of 'weekly', but then override that setting with a 'size' setting for certain log files.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
(This is an enhancement request.  There is no problem that causes unexpected results.)

Additional info:
Comment 1 Glenn Zazulia 2005-11-21 01:38:14 EST
Created attachment 121290 [details]
Patch to add 'minsize' directive

This is my suggested patch to implement my described enhancement.
Comment 2 Peter Vrabec 2006-05-09 08:07:27 EDT
Created attachment 128779 [details]
patch adjusted to logrotate 3.7.3

Glenn, could u review this patch. I moved 
if (log->minsize && sb.st_size < log->minsize)
	    state->doRotate = 0;
to different place. I think it would be better not to override all criteria
especially force option.
Comment 3 Peter Vrabec 2006-05-09 08:14:24 EDT
Could you propose any comment about minsize option, which I can use in logrotate man page? 
Comment 4 Glenn Zazulia 2006-05-16 18:32:04 EDT
Created attachment 129278 [details]
Suggested logrotate man page addition for minsize

Here is a suggested addition to the logrotate man page for the new minsize
option.  (See attached patch.)

I also reviewed your modified patch, and although I haven't tested it much yet,
it looks fine.	I just installed this latest version.
Comment 5 Peter Vrabec 2006-05-17 11:52:25 EDT
Thanks for man page. New "minsize" directive is in logrotate-3.7.4-1.

Note You need to log in before you can comment on or make changes to this bug.