Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
I am seeing the same behaviour on a CentOS 5.5 VM running on XenServer 5.0.0 build 13192p. –  Xhantar Nov 16 '11 at 9:21

2 Answers 2

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

Or better still use NTP.

share|improve this answer
    
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 '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; unixhelp.ed.ac.uk/CGI/man-cgi?date –  Chopper3 Feb 8 '10 at 12:57
    
+1 for the NTP suggestion –  Antoine Benkemoun Feb 8 '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 8 '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 8 '10 at 14:05

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.