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.

1
  • I am seeing the same behaviour on a CentOS 5.5 VM running on XenServer 5.0.0 build 13192p.
    – Xhantar
    Nov 16, 2011 at 9:21

2 Answers 2

1

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

Or better still use NTP.

6
  • 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 8, 2010 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; unixhelp.ed.ac.uk/CGI/man-cgi?date
    – Chopper3
    Feb 8, 2010 at 12:57
  • +1 for the NTP suggestion Feb 8, 2010 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 8, 2010 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 8, 2010 at 14:05
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .