根据documentation,tar
是能够保存访问时间,但是当我尝试相同时,它没有这样做。有人可以解释这个吗?为什么一时没有保存在焦油?
$$$:~/user1/testtar/source> tar --version
tar (GNU tar) 1.15.1
与旧的时间戳创建两个文件
$$$:~/user1/testtar/source> touch -t "201501010101" a.txt
$$$:~/user1/testtar/source> touch -t "201501010101" b.txt
$$$:~/user1/testtar/source> ls -ltu
-rw-r--r-- 1 usr usr 0 2015-01-01 01:01 a.txt
-rw-r--r-- 1 usr usr 0 2015-01-01 01:01 b.txt
将其移动到另一个文件夹
$$$:~/user1/testtar/source> tar --atime-preserve -cvpf archive.tar *
$$$:~/user1/testtar/source> mv archive.tar ../target/
$$$:~/user1/testtar/source> cd ../target/
提取tar
$$$:~/user1/testtar/target> tar --atime-preserve -xvpf archive.tar
a.txt
b.txt
$$$:~/user1/testtar/target> ls -lt
total 12
-rw-r--r-- 1 usr usr 10240 2016-07-07 15:55 archive.tar
-rw-r--r-- 1 usr usr 0 2015-01-01 01:01 a.txt
-rw-r--r-- 1 usr usr 0 2015-01-01 01:01 b.txt
结果
$$$:~/user1/testtar/target> ls -ltu
-rw-r--r-- 1 usr usr 10240 2016-07-07 15:56 archive.tar
-rw-r--r-- 1 usr usr 0 2016-07-07 15:56 a.txt
-rw-r--r-- 1 usr usr 0 2016-07-07 15:56 b.txt