tar: Exiting with failure status due to previous errors

We often use the tar command in our web site and system operations. This is a very useful command, it hardens the whole directory and compresses it if you want.
You may say zip is good, but on Unix-like operating systems, tar is traditionally used and gzip is often used as a compression format.

Common Error

Occasionally, a command
tar cvzf public_html.20190918.tar.gz public_html

might produce a captioned error.
※Command description omitted

tar: Exiting with failure status due to previous errors

Even if you say previous errors…

The tar command was being executed in good condition until a while ago. and you’re looking at the log like this,

tar: Exiting with failure status due to previous errors

I can’t find “previous errors” anywhere. If you search for an error message on Google, you will see a lot of information saying that this error may occur if you have a file that you do not have read permissions for.

The article also says that you can execute

find . perm 000

to look for files that you don’t have read access to.

Yes, it may be so.

However, it just so happens that the server I was touching during this time was limited in the commands it was running and I couldn’t run find.

What’s wrong… Where is the root cause file…


I found this information.

The tar
 command should actually print out what those “previous errors” are, but you can easily miss printed error messages if you run tar
 in verbose mode (e.g., -cvf).


And the solution is,

 tar cvfz backup.tgz my_program/ > /dev/null

Throwing standard output to/dev/null will only cause errors.

It’s better to know the correct cause of the error than to find it without knowing whether the cause is a read right or not.