Setting time on Ubuntu server

I had a lot of trouble setting my Ubuntu server's system clock. date, ntpdate, and the ntp severver daemon will are failing to set the date/time. Apparently if you are running linux with 2.6.18 kernel you need to detach from the host's clocksource with:

$ echo 1 > /proc/sys/xen/independent_wallclock

How do you tell what version of the kernel you are running? :

$  uname -a

uname will output thew kernel version. If its 2.6.18.x, then run the echo command above.

Then you can simply user the date command to set the date/time.

date --set="YYYY-MM-HH-mm-ss"

or use ntpdate

ntpdate pool.ntp.org