delaycompress in relevant log rotation configuration files may help with the first error.
This can be done as default here
/etc/logrotate.conf or more specifically in any of the package specific configuration files in
delaycompress (emphasis added):
Postpone compression of the previous log file to the next rotation cycle. This only has effect when used in combination with compress. It can be used when some program cannot be told to close its logfile and thus might continue writing to the previous log file for some time.
so if you add it in the global config file you need to add
compress too, which you might not want to do.
Alternatively, you need to track down which package is problematic - not easy but here are some hints:
- Discover which config files have the
compress option on:
cd /etc/logrotate.d and then
grep "compress" *
- Of these, find out which ones don't also have
- Compare with the last rotated time in
/var/lib/logrotate/status and the size of the log file, and with a bit of inference & hand waving you might have narrowed it down sufficiently
- Then add
delaycompress to the relevant config file e.g.