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 commandtar 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,
public_html/img/D1550FD.jpg public_html/img/L1-20DT.jpg public_html/img/delivery.html public_html/img/B7001DT.jpg public_html/img/YM1601D.jpg public_html/img/YM1502D.jpg public_html/img/L1501.jpg public_html/img/L1500DT.jpg public_html/img/B7000DT.jpg public_html/img/YM2210D.jpg public_html/img/B1500.jpg public_html/img/SD2040D.jpg 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…
Countermeasures
I found this information.
The tar
http://ask.xmodulo.com/tar-exiting-with-failure-status-due-to-previous-errors.html
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.