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?
Asked
Active
Viewed 1.8k times
21
brendon-ai
- 321
- 1
- 2
- 6
1 Answers
28
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 ...
Stephen Kitt
- 411,918
- 54
- 1,065
- 1,164