22

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?

1 Answer 1

30

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 ...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .