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.

I have a XEN domU running CentOS 5.

I'm having trouble setting the correct timezone.

I want it to run on Mountain Standard Time, but it shows Pacific Standard time. I've tried everything, but I can't get this right. This VM doesn't have Internet access, so I can't use ntpd or anything. I sync it up with another Xen domU running XP, which has the correct timezone and time. But even if I don't sync up, it should show me the correct timezone, since I'm pointing /etc/localtime at the correct timezone.

Here's all the commands (and output for some) I've used so far.

# mv /etc/localtime  /etc/localtime-old

# ln -sf /usr/share/zoneinfo/US/Mountain /etc/localtime

# vi /etc/sysconfig/clock

ZONE="America/Denver"
UTC=true
ARC=false

# /usr/sbin/tzdata-update

# /sbin/hwclock --systohc --utc

# uname -a
Linux MyServer 2.6.18-164.6.1.el5 #1 SMP Tue Nov 3 16:18:27 EST 2009 i686 athlon i386 GNU/Linux

Now when I type date it shows PST # date Thu Apr 7 16:29:34 PDT 2011

ntpd is not running

What's missing?

share|improve this question
add comment

4 Answers

Do you use a PV Xen DomU? If so, your time is coupled with the Dom0. If you want to change that, do a sysctl -e xen.independent_wallclock = 1

After that timezone, ntpdate and ntp will function as expected.

share|improve this answer
    
Oh - that was easy. ;-) So for these points just an additional comment: To make it reboot-safe add xen.independent_wallclock = 1 to /etc/sysctl.conf –  Nils Oct 17 '11 at 19:00
add comment

You do realize that uname -a is displaying the date and timezone information from when the kernel was actually built? That changing the timezone settings will not affect the results of uname -a timezone display unless you recompile your kernel.

For a domU to run ntpd you will need to set the xen.independent_wallclock sysctl value to 1 as Nils mentions but that won't affect the timezone displayed via uname -a. Otherwise all the other steps you show as having taken should affect the timezone on your machine and if the results of simply running date returns the timezone you're expecting then it is complete and your test of using uname -a to verify is all that is invalid.

share|improve this answer
add comment

Is it possible the TZ environment variable is set for your user? TZ will override /etc/localtime with a different timezone. Run "echo $TZ"

share|improve this answer
    
There's no TZ environment variable set. –  Amit Phatarphekar Apr 7 '11 at 23:54
    
I'm not sure, but nscd might cache the timezone info... you might try restarting it. –  mfarver Apr 8 '11 at 0:33
add comment
up vote -2 down vote accepted

I ended up synching the troubled machine with another machine every minute, just using simple ntpdate command run from a script invoked via crontab every minute.

share|improve this answer
1  
seriously, how this can be a good solution? –  Giovanni Toraldo Oct 16 '11 at 17:46
add comment

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.