Ubuntu NTPd Time Server
Ubuntu time/date with NTP daemon
ntpdate runs on system boot and (theoretically) sets the clock, but if your are using a server / leave your pc on a long time / network isnt up when it tries, then time drifts. Either set a cron job to run it constantly or use ntp daemon to keep it constantly tweaked.
Install
Check what/if anything currently running
ps aux | grep -i ntp #or sudo service ntp status
If nothing is running install ntp
sudo apt-get install ntp
This should immediately sync and just work. The default time servers (e.g. server 1.ubuntu.pool.ntp.org) etc. are in /etc/ntp.conf
ntp.conf
Can add working servers to /etc/ntp.conf. Add a line in the config file like this.
#Use Ubuntu's ntp server as a fallback. server ntp.ubuntu.com #My own fallback server server ntp3a.le.ac.uk
Fix
Sometimes it doesn't sync (possibly if its miles out?) automatically, to manually force a resync you must stop ntp service, manually run ntpdate (wont work with service still running) , then restart ntp service.
$ sudo service ntp stop #enter a working NTP server e.g. time.windows.com or ntp3a.le.ac.uk $ sudo ntpdate time.windows.com 7 Apr 11:26:38 ntpdate[15270]: step time server 65.55.21.13 offset -105.920608 sec #clock should now be corrected $ sudo service ntp start
You may need to try several servers before you find one that works! When you do it may be worth tagging this into /etc/ntp.conf