Reputation: 21
I'm trying to setup a rather simple logrotate and from what i gather it should be supporting the maxage
option mentioned here (https://linux.die.net/man/8/logrotate). It's also mentioned under my man logrotate
.
I'm running logrotate 3.8.6
.
So i would like to simple rotate based on age and not using the rotate counter. I see lots of example where people use both with rotate and maxage together. But from what i understand in the man it shouldn't be impossible to use just maxage.
Basically i have the scenario where i have multiple rotations pr day of a given logfile so i cannot predict the rotate count in any way. And setting it to a huge oversized number is a major performance hit as well as a pain in the behind to debug with -v.
So just looking to keep ALL log files from within a X day period that could potentially be rather large window of several years.
Any ideas ?
Upvotes: 2
Views: 4981
Reputation: 1215
Per the manpage:
rotate *count*
Log files are rotated count times before being removed or mailed to the address specified
in a mail directive. If count is 0, old versions are removed rather than rotated. Default
is 0.
The default for this value is zero if you don't set it, meaning it deletes everything it rotates out. You can see this from the debug dump, first with my existing config (rotate 4):
rotating pattern: /var/log/boot.log
after 1 days (7 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/boot.log
log does not need rotating (log is empty)
rotating pattern: /var/log/chrony/*.log weekly **(4 rotations)**
versus when I comment that line out and leave it undefined anywhere:
rotating pattern: /var/log/boot.log
after 1 days (7 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/boot.log
log does not need rotating (log is empty)
rotating pattern: /var/log/chrony/*.log weekly **(no old logs will be kept)**
One of the main purposes of logrotate is to manage the amount of space logs take up; having it rotate into infinity without ever removing anything goes against that purpose. You didn't post your actual configuration file either so I don't know what other parameters you're rotating against.
If you're rotating multiple times a day, my primary suggestion would be to regularly move those already-rotated logs out of that directory so that logrotate never considers them again. Your configuration becomes much simpler that way.
Upvotes: 1