- keep the logs of deleted instances for N days
- not rotate/delete the logs of shutdown instances
- not rotate (and then lose) the last messages logged by running instances
The main changes to the current default are
- replace 'minsize 100k' by 'notifempty': this is mostly to not rotate empty logs, but to none the less ensure the 'lastaction' script is run whenever there is actually a change (lastaction is *only* run by logrotate when some rotation happened);
- add a lastaction script: this is meant to preserve the logs of all instances that still exist and should expire out the logs of deleted instances after 30 days.
There is at least one issue with this apparoach: logrotate will need 4 weeks before the first logs are deleted, so an initial cleanup may be needed for compute nodes that piled up logs.
In order to
- keep the logs of deleted instances for N days
- not rotate/delete the logs of shutdown instances
- not rotate (and then lose) the last messages logged by running instances
how about:
--> libvirt/ qemu/*. log {
delaycompress
copytruncate
keep= `virsh list --all|grep instance|awk '{print "! -name "$2".log*"}'`
find /var/log/ libvirt/ qemu/ -type f -mtime 30 $keep -exec rm {} \;
/var/log/
weekly
missingok
rotate 4
compress
notifempty
lastaction
endscript
}
<--
The main changes to the current default are
- replace 'minsize 100k' by 'notifempty': this is mostly to not rotate empty logs, but to none the less ensure the 'lastaction' script is run whenever there is actually a change (lastaction is *only* run by logrotate when some rotation happened);
- add a lastaction script: this is meant to preserve the logs of all instances that still exist and should expire out the logs of deleted instances after 30 days.
There is at least one issue with this apparoach: logrotate will need 4 weeks before the first logs are deleted, so an initial cleanup may be needed for compute nodes that piled up logs.