4

I ran below command:

tar cvf ~/data.tar /home/user/data/

It showed lot of filenames on the screen, after 10 minutes I see:

tar: Exiting with failure status due to previous errors

Where can I see the error log for tar (is it somewhere under /var/log). I can see that there is 100 Mb difference between the tarred version and the original. I want to know the names of missing files from newly created archive.

du -sh data.tar /home/user/data
5.7G     data.tar
5.8G      /home/user/data

Using GNU tar 1.27.1

marked as duplicate by Thomas Dickey, Anthon, Networker, Kusalananda, heemayl Aug 15 '16 at 13:14

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • The question is useful, but if it's a backup, I would advise restarting the operation from scratch. Some files could be in the archive already, but corrupted because tar exited while writing them. – Elzo Aug 15 '16 at 10:57
9

tar is an interactive command, not a service and does not produce log files.

Its output is sent to stdout and errors to stderr.

You can redirect the output streams to files, but you would need to run it again.

tar cvf ~/data.tar /home/user/data/ > tar_stdout.log 2> tar_stderr.log

And examine the contents of the file tar_stderr.kog.

Or combine both streams into one file:

tar cvf ~/data.tar /home/user/data/ &> tar.log
4

Since your tar was pretty large you may not want to repeat it and collect the errors as in the other answers, so do a sort of dummy version to /dev/null dropping the v option and keeping the errors:

tar cf /dev/null /home/user/data/ 2>errors
  • I tried this, errors contains tar: Removing leading / from member names No other error. – user13107 Aug 15 '16 at 8:27
  • 1
    Running the real command again showed additional errors, such as Permission denied errors. – user13107 Aug 15 '16 at 8:32
  • That's bad luck. Must be an OS difference. Works for me with gnu tar 1.28. (tar --version). Eg on /tmp I get errors like tar: /tmp/.X11-unix/X0: socket ignored, and tar: /tmp/nspawn-root-9rooX8: Cannot open: Permission denied. – meuh Aug 15 '16 at 8:32
  • You can avoid some of the i/o overhead by piping the tar output to /dev/null. It's not as fast since it still has to read all the data, but at least you dont write it all again: tar cf - /home/user/data/ 2>errors | cat >/dev/null – meuh Aug 15 '16 at 8:39
3

You would have to capture the log while you are untarring the file, e.g.,

tar cvf ~/data.tar /home/user/data/ 2>tar.errors |tee tar.output

to put the errors in tar.errors, watch the normal output, and put that in tar.output.

Not the answer you're looking for? Browse other questions tagged or ask your own question.