The Linux Page

tar: .../public_html/wp-content: file changed as we read it

I created a little script to generate a daily tarball as a backup of a customer website.

Everyday, though, I would get the following error:

tar: .../public_html/wp-content: file changed as we read it

As you can see, the website is using Wordpress.

The error, though, I could not replicate when I would run the tar command by hand. What gives?

Looking closer into it, I noticed that my crontab setup would actually run the cron.php at the same time as the backup would run:

# m h  dom mon dow   command
  0 3  *   *   *     /.../backups/backup.sh

*/10 * *   *   *     cd /.../public_html && php -q wp-cron.php

As we can see in the crontab, the Wordpress wp-cron.php script runs every 10 minutes, including at 03:00 in the morning as the backup.sh script was be started too.

The trick was to change the backup.sh startup minutes to something else, assuming the wp-cron.php script was fast enough (i.e. did not take 5 min. to run) then backup.sh will be running on its own (unless a customer works at 03:05 in the morning?)

# m h  dom mon dow   command
  5 3  *   *   *     /.../backups/backup.sh

*/10 * *   *   *     cd /.../public_html && php -q wp-cron.php

So I changed the 0 into a 5 and the tar error was gone.

SMS From Me Logo

SMS From Me

To automatically start one on one conversations with your online leads.