1

The time on a Xen VM running CentOS 5 is incorrect. Running the date command seems to result in the expected output, but subsequent calls to date still show the incorrect time.

[xxx@xxx ~]$ sudo date -s "2010-02-08 12:26:00"
Mon Feb  8 12:26:00 GMT 2010
[xxx@xxx ~]$ date
Mon Feb  8 17:26:58 GMT 2010

Any ideas? Thank you.

Ben James
  • 21
  • 3

2 Answers2

1

Try a '-u' before the '-s'.

Or better still use NTP.

Chopper3
  • 101,299
  • 9
  • 108
  • 239
  • The `-u` doesn't seem to make any difference. NTP is a good suggestion, but I am interested in understanding what is going wrong here. – Ben James Feb 08 '10 at 12:47
  • ok, it's almost certainly just a timezone issue given it's out by pretty much whole hours - I imagine your machine thinks it's in NYC when you're in the UK or similar - have a look here; http://unixhelp.ed.ac.uk/CGI/man-cgi?date – Chopper3 Feb 08 '10 at 12:57
  • +1 for the NTP suggestion – Antoine Benkemoun Feb 08 '10 at 13:09
  • "almost certainly just a timezone issue" - but look at the output I gave, both cases show "GMT" which is correct. – Ben James Feb 08 '10 at 13:40
  • 1
    Antoine, what makes you think `ntpd` will be able to set the date when I can't do it myself? – Ben James Feb 08 '10 at 14:05
  • some checks then, what's your /etc/localtime? is it a SL to a file in /usr/share/zoneinfo? if so which file? also are you running rdate? what's in your etc/sysconfig/clock file? also try '/sbin/hwclock --systohc' – Chopper3 Feb 08 '10 at 14:11
1

The issue is that on a Xen VPS, it isn't possible to set the date at all!

So since I have no control over the underlying hardware (which seemed to be on GMT+5 yet thought it was on GMT), the solution was to set my timezone to GMT+5.

Ben James
  • 21
  • 3