13

I am using tar to package a number of files. Modify timestamps on the files are critical, and must be of high accuracy. Using tar -cvf, timestamps are preserved but rounded to the nearest second, i.e. running stat on the files displays only timestamps that end in .0. Is there a way to preserve timestamps to greater accuracy, or is there a different archive tool I can use for this purpose?

18

The usual tar format stores timestamps as a number of seconds, as you determined. To store timestamps with more resolution, you need to use another format, such as POSIX tar as produced by GNU tar which stores timestamps in nanoseconds (usually).

To create these archives, use the -H posix option with GNU tar:

tar cfH archive.tar posix ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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