0

I have a ubuntu 10.04 system in a openvz contaioner.

now, I get a problem of the time & time zone.

I have change my timezone to Asia/Shanghai by the command:

sudo dpkg-reconfigure tzdata

and it get work when I run command:

~$ date
2013年 02月 24日 星期日 12:00:05 CST

But if I touch a file, the file's modifier time is in the future!

~$ touch somefile
~$ ls -l
total 1
-rw-r--r-- 1 chen chen 0 2013-02-24 20:07 somefile

Note that the new touched file somefile has a 8 hours future time!! how it happend!!

~$ ls --full-time
total 1
-rw-r--r-- 1 chen chen 0 2013-02-24 20:07:33.340285883 +0800 somefile
cjh75
  • 1

1 Answers1

0

Touch hasn't been aliased has it? That is the command touch isn't an alias for touch -d '+8 hours' or something like that?

ojs
  • 492
  • 4
  • 13
  • normal create file such as `vim newfile` will cause the same problem. – cjh75 Feb 24 '13 at 06:59
  • The system is just a new installed system. All things are right at First. Just When I changed my TimeZone, the problem occured. – cjh75 Feb 24 '13 at 07:02
  • Ok, then the hardware clock is most probably set to Singapore and the TimeZone is adding an extra 8 hours to it. This might help you out http://forum.openvz.org/index.php?t=msg&th=1662&start=0& – ojs Feb 24 '13 at 14:07
  • Thanks for you comments. I checked my vps host's TimeZone. It is the +8 zone. So I think the `touch` command use the host's timezone, +8 hours to the GMT time, then in the vps, +8 hours again. May I change the Host's TimeZone to GMT TimeZone? – cjh75 Feb 25 '13 at 00:41
  • Your hardware clock on the host should be UTC/GMT then the timezone should be set correctly on that host and the VPS also. So they should both read the hardware clock and adjust their time according to the timezone. – ojs Feb 26 '13 at 13:41