[SOLVED] Cron Error?

Not real sure at all what this means. I get this every few days through an email…

Email Subject: Cron root@openHABianPi test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

Email Body: /etc/cron.daily/logrotate:

error: Compressing program wrote following message to stderr when compressing log /var/log/mosquitto/mosquitto.log.1:

gzip: stdin: file size changed while zipping


I’m going to be really thorough in my explanation. I’m not trying to be pedantic so much as explaining what is going on for future readers of this thread.

First, where is this email coming from? It’s coming from your operating system. You’ve set up email properly on your machine (good for you!) or openHABian did it so whenever the operating system runs into some major problem it will send an email to you.

Next, what is causing it? The cron daemon on Linux is a service whose job is to run a script periodically. In this case it is running the script /etc/cron.daily/logrotate. And we can tell this is a script that runs every day because it is in the cron.daily folder.

What does this script do? This is one of the more important cron scripts. It is responsible for rotating your logs so they don’t fill up your file system. There are usually ten files that make up the logs from a service.

  • service.log - the active log file
  • service.log.1 - yesterday’s log file
  • service.log.2.gz - compressed version of the log file from two days ago
  • and so on through service.log.9.gz

Every day the logrotate script runs and deletes service.log.9.gz, promotes service.log.2.gz through service.log.8.gz to the next number. Then it compresses service.log.1 to service.log.2.gz. Finally, it copies service.log to service.log.1 and empties out service.log to start the logging for the new day.

What does the error mean? When the script tries to compress mosquitto.log.1 to mosaquitto.log.2.gz it can’t because the file is actively changing.

This should not be happening. All new log entries need to be saved to mosquitto.log, not mosquitto.log.1.

Something is writing to this file. In all likelihood something is going wrong during the rotate causing mosquitto to write to the .1 file. What can be causing this?

Sadly, the most likely cause I can think of is your SD card is failing. When I last had an SD card failure I discovered it because of strange behavior on the log rotation like this.


Thanks Rick, as usual, great information! I have probably been living on a prayer for the last year. That disk has been in that greenhouse cranking away for a year! Probably time to change it out!