Need Assistance?

In only two hours, with an average response time of 15 minutes, our expert will have your problem sorted out.

Server Trouble?

For a single, all-inclusive fee, we guarantee the continuous reliability, safety, and blazing speed of your servers.

How to Resolve “gzip: stdin: file size changed while zipping” Error in Logrotate

Linux servers with cPanel may occasionally encounter an error during log rotation “gzip: stdin: file size changed while zipping”

error: Compressing program wrote following message to stderr when compressing log /var/log/cpanel-server-traffic/web/traffic-apache.log:
gzip: stdin: file size changed while zipping.

This message typically appears when the /etc/cron.daily/logrotate job runs. Although it seems concerning, it’s usually not harmful and doesn’t indicate data loss or failure in log rotation.

What Causes the Error ” gzip: stdin: file size changed while zipping “

The error “gzip: stdin: file size changed while zipping” occurs when a log file is being written to while gzip is compressing it. Since many services (like Apache, MySQL, etc.) write logs continuously, it’s possible for the file size to change mid-process, triggering this warning. This is especially common on busy servers with high logging activity.

Is It Critical?

No, this message is usually just a warning. Logrotate often completes the operation successfully despite the message. The log file gets compressed, and the rotation cycle continues normally.

How to Prevent the error “gzip: stdin: file size changed while zipping?

To resolve this warning, update your logrotate configuration to include appropriate compression flags. Here’s how:

  • Access the Server via SSH as the root user.
  • Edit the logrotate config file for the affected service in /etc/logrotate.d/ directory using your preferred text editor. In this case, the apache logrotate is getting edited. If you are confused about the configuration, try to grep the log file mentioned in the error.
  • Ensure the configuration includes both compress and delaycompress directives, in that order.

For example:

/var/log/cpanel-server-traffic/web/traffic-apache.log {
    rotate 5
    daily
    compress
    delaycompress
    missingok
    extension traffic-apache.log
    dateext
    dateformat %Y-%m-%d-
    dateyesterday
}

The delaycompress option tells logrotate to compress the previous log file instead of the current one, avoiding the size change conflict during compression.

  • Save the file, and the configuration will be used the next time logrotate runs against that log file.

Conclusion

While the gzip warning may not indicate a failure, updating your logrotate configurations with compress and delaycompress is a clean and effective way to eliminate the message. It’s a simple tweak that helps ensure smoother log management and cleaner system logs over time.

If you’re still facing the error or need help fine-tuning your log rotation setup, our expert team is here to assist you. At Skynats, we specialize in Linux Server Management services to ensure your systems run smoothly, securely, and without interruption. Contact us today for reliable, professional support tailored to your server environment.

Liked!! Share the post.

Get Support right now!

Start server management with our 24x7 monitoring and active support team

Let us know your requirement.

Can't get what you are looking for?

Get Support Right Away!

Thank You

We have received your query and will get back to you soon.