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): logrotate-3.7.1-10 How reproducible: Sometimes Steps to Reproduce: (This is an enhancement request. There is no problem that causes unexpected results.) Additional info:
Created attachment 121290 [details] Patch to add 'minsize' directive This is my suggested patch to implement my described enhancement.
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.
Could you propose any comment about minsize option, which I can use in logrotate man page?
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.
Thanks for man page. New "minsize" directive is in logrotate-3.7.4-1.