Software⏱️ 3 min read📅 2026-06-11

How to Fix: TAR error — `wp-content: file changed as we read it`

Error occurs when trying to create a tarball in WordPress directory due to file system issues.

Quick Answer: Check if the WordPress home folder has any permissions or configuration issues that might be causing the error.

The TAR error 'file changed as we read it' occurs when the tar command attempts to archive a file that has been modified since the last time the archive was written. This issue affects users who run tar commands within specific directories, causing the backup process to fail.

This error can be frustrating for web developers and system administrators who rely on regular backups of their WordPress sites. However, by following these steps, you can determine the cause of this error and implement a solution to resolve it.

🛑 Root Causes of the Error

  • The primary reason for this error is that the tar command is attempting to archive files within the same directory where the tar file is being created. This causes the tar command to read the file while it's still open, resulting in a 'file changed as we read it' error.
  • An alternative cause could be that the WordPress site's wp-content directory contains symbolic links or other special files that are causing the tar command to fail.

🚀 How to Resolve This Issue

Checking the directory structure and file permissions

  1. Step 1: Run the `ls -l` command to verify that the wp-content directory is not a parent of the backup directory. This will help you determine if the issue is due to the tar command trying to archive files within the same directory.
  2. Step 2: Check the file system permissions for the wp-content directory and ensure that the user running the tar command has read access to all files and directories within the directory.
  3. Step 3: Verify that there are no symbolic links or special files within the wp-content directory that could be causing the tar command to fail.

Modifying the tar command to exclude the wp-content directory

  1. Step 1: Modify the tar command to exclude the wp-content directory by adding the `-P` option, which tells tar to use a pseudodirectory for the archive. For example: `tar --exclude='./wp-content' -P /home/waiheke26/sites/www.DOMAIN.co.nz/backups/wp-files-$(date +%Y-%m-%d-%H.%M.%S).tar.gz .`
  2. Step 2: Test the modified tar command to ensure that it can successfully archive the WordPress site's files.

✨ Wrapping Up

By following these steps, you should be able to determine the cause of the TAR error 'file changed as we read it' and implement a solution to resolve it. Remember to regularly check your directory structure and file permissions to prevent this issue from occurring in the future.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions