Which logs are you concerned about? Other than the recent issues, for many years there has not been an issue. I think we are trying to fix something that does not need fixing.
But we do have timed rotation. In fact, logrotate, as setup, only triggers to test for rotation on a fixed time schedule and it will then decide on the rotation to be carried out depending on what rule has been reached (size or time). For true SIZE/MAXSIZE rotation you need monit to monitor the SIZE of the log files and trigger the rotation if necessary.
I really dislike olddir
as several packages use error.log
in a folder and olddir
cannot distinguish between them. It is pointless in the emonhub configuration IMHO even with Log2RAM.
I currently use a post rotate command to move out the emonhub file to persistent memory (as Iāve mentioned before) - much more robust IMHO.
/var/log/emonhub/emonhub.log {
rotate 6
daily
size 2M
maxsize 2M
missingok
copytruncate
notifempty
postrotate
mv /var/log/emonhub/emonhub.log.1 /home/pi/data/
cat /home/pi/data/emonhub.log.1 >> /home/pi/data/emonhub.log
rm /home/pi/data/emonhub.log.1
endscript
}
/home/pi/data/emonhub.log {
su pi pi
rotate 10
daily
compress
missingok
notifempty
}
Of course it isnāt working right now as the update buggered up the logrotate setup as usual.
For /var/log
- rotation number does not matter but just stops it growing if something goes wrong
- daily - at the very least rotate daily
- size/maxsize - rotate once this big
- copytruncate - this seems to work without loss AFAICS.
For /home/pi/data/
- keeps 10 daily logs compressed.