How can I fix "/etc/cron.daily/logrotate: gzip: stdin: file size changed while zipping"?

Kiuki picture Kiuki · Jul 1, 2015 · Viewed 16.6k times · Source

in last days i get daily mail from cron's logrotate task:

/etc/cron.daily/logrotate:

gzip: stdin: file size changed while zipping

How can I fix it?

Thanks, Gian Marco.

Answer

lamanux picture lamanux · Aug 17, 2015

Here's a blog post in French which gives a solution.

In English, you can read this bug report.

To summarise:

  1. First you have to add the --verbose option in the script /etc/cron.daily/logrotate to have more information the next time it runs to identify which rotation log cause the problem.

    #!/bin/sh
    
    test -x /usr/sbin/logrotate || exit 0
    /usr/sbin/logrotate --verbose /etc/logrotate.conf`
    
  2. Next you have to add the delaycompress option in logrotate configuration.

    Like exemple, I add the nginx's logrotate configiguration in /etc/logrotate.d/nginx:

    /var/log/nginx/*.log {
        daily
        missingok
        rotate 14
        compress
        delaycompress
        notifempty
        create 0640 www-data adm
        sharedscripts
        ...
    }