Linux – time stamp XXXX s in the future issue – touch command (Linux)

debianlinuxtimestamptouchunix

When I untar a tar.gz file on Debian Lenny, I get the such outputs:

tar: openssl-1.0.1e/apps/openssl.cnf: time stamp 2013-02-11 15:26:04 is 1360584537.139999998 s in the future
openssl-1.0.1e/apps/openssl-vms.cnf
tar: openssl-1.0.1e/apps/openssl-vms.cnf: time stamp 2013-02-11 15:26:04 is 1360584537.129999998 s in the future
openssl-1.0.1e/apps/passwd.c

I see that the time stamp of the file is in the future comparing the system's time. I use touch as below to change the time stamp of the file, and stat shows that the time stamp of the file is the system's current time, then I attempt to untar the file, but I still get the same time stamp problem (as above).

ts7500:/home# touch -am openssl-1.0.1e.tar.gz 
ts7500:/home# stat openssl-1.0.1e.tar.gz 
  File: `openssl-1.0.1e.tar.gz'
  Size: 4459777         Blocks: 8736       IO Block: 4096   regular file
Device: 2b09h/11017d    Inode: 40802       Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 1970-01-01 03:15:24.000000000 +0000
Modify: 1970-01-01 03:15:24.000000000 +0000
Change: 1970-01-01 03:15:24.000000000 +0000
ts7500:/home# date
Thu Jan  1 03:15:48 UTC 1970
ts7500:/home# tar xvf openssl-1.0.1e.tar.gz

I know that I can solve the problem by changing the system's time by date -s "08 JUN 2013 00:19:00" or use NTP. But I wonder, why changing the time stamp of the file by touch did not work? how should I have changed the time stamp of the file, so that I would not have that warning?

If you want to see the file system:

ts7500:/home# blkid
/dev/nbd6: SEC_TYPE="msdos" UUID="01E8-4C7D" TYPE="vfat" 
/dev/nbd8: UUID="236b63b3-15db-40c3-bc5f-e4b7c4b10751" TYPE="ext2" 
/dev/nbd9: UUID="5b13aa84-e589-41a7-84cf-2d0d6bf2a9cd" TYPE="ext3" 
ts7500:/home# df -Th
Filesystem    Type    Size  Used Avail Use% Mounted on
tmpfs        tmpfs     31M  4.0K   31M   1% /lib/init/rw
udev         tmpfs     10M  160K  9.9M   2% /dev
tmpfs        tmpfs     31M     0   31M   0% /dev/shm
rootfs      rootfs    3.3G  1.7G  1.5G  53% /
/dev/root     ext2    2.0M  1.7M  311K  85% /initrd

Best Answer

It did not work because you changed the timestamp of the archive, not of the files it contains. If you run stat on the tar.gz file you will find that the time was changed correctly. touch cannot access the files stored within the archive until you extract them so they were left unchanged.

In any case, this should not be a problem, just untar the archive, then change the timestamp of the files:

mkdir foo
mv openssl-1.0.1e.tar.gz foo/
cd foo/
tar xvvzf openssl-1.0.1e.tar.gz
find . -exec touch -am '{}' \;
Related Question