tar -cf not preserving exact modification time
28 Репутация автора
When creating a tar archive with
-c, the modification time seems to be changing, specifically it cuts off the time after the decimal, leaving the modtime to be just the integer value of what it was.
[localhost] $ mkdir test [localhost] $ stat test File: ‘test’ Size: 4096 Blocks: 8 IO Block: 4096 directory Modify: 2016-07-18 17:01:33.116807520 -0400 # <------ Notice exact time [localhost] $ tar -cf test.tar test [localhost] $ tar -xf test.tar [localhost] $ stat test File: ‘test’ Size: 4096 Blocks: 8 IO Block: 4096 directory Modify: 2016-07-18 17:01:33.000000000 -0400 # <------ Notice how time is rounded
(I removed irrelevant parts from output of
stat for readability)
man tar, but couldn't find an option that'll preserve exact modification time in nanoseconds. Could someone explain why such behavior is occurring? Or is this expected during tar creation.
Update: So far no luck, I tried playing around with
tar options but most of options that deal with time are related to a files' access time, and not modtime. The ones that do deal with modtime change the modtime, which isn't something I'm looking for.
21 Репутация автора
Just in case anyone googling the same issue stumbles upon this thread (like I did):
The solution (at least one of them) is to use the -H option, as answered here:
The tar(1) manpage does not point out the practical implications of the -H arguments at all; I think it would be very helpful if a search for a likely keyword ("nanosecond", "second", "resolution", etc.) led to the paragraph on -H.Автор: vich Размещён: 16.03.2018 11:46