problem : when I try to create a compressed file with tar command, I always fail in the process of execution, and throw an error description “tar: exiting with failure status due to previous errors”
If you encounter the following error when you execute the tar command, the most likely reason is that you do not have read permission for a file you want to compress with the tar command
tar: Exiting with failure status due to previous errors
So how do we identify the file (s) that caused the error?Or how to identify other sources of error
In fact, the tar command should print out what the so-called “previous errors” are, but if you let tar run in detailed mode (i.e. – CVF), you will easily miss this information. To find this information, you can filter out tar’s stdout information as follows
tar zcvf backup.tar.gz my_program/ > /dev/null
and then you’ll see the stderr output from tar( Lctt: naturally, it’s OK without the V parameter.)
tar: my_program/src/lib/.conf.db.~lock~: Cannot open: Permission denied
tar: Exiting with failure status due to previous errors
As you can see from the above example, the cause of the error is indeed “denied read permission”. To solve this problem, simply change (or remove) the permission of the problem file, and then re execute the tar command