0

I have recently noticed that the time on my computer isn't the same as on the others in my household, and I'm not sure if it's just them, or whether my machine has actually got the wrong time...

So I was wondering if there is some way through Terminal of synchronizing my computer clock with the Ubuntu servers or something? Or at least being able to check that I have the right time for my time zone?

I am running Ubuntu GNOME 15.10 with GNOME 3.18.

1

There should be an option to enable network time synchronization in the Date & Time section in your system settings. If however this is too inaccurate, you can enforce NTP time synchronization with the ntpdate command (you will need to install this with sudo apt-get install ntpdate as it is not installed by default on 15.10):

sudo ntpdate ntp.ubuntu.com

After fetching the current time from the server, it will tell you the offset to the machine's own clock and automatically adapt it:

 7 Dec 22:27:57 ntpdate[14411]: adjust time server 91.189.94.4 offset -0.049344 sec

If you're experiencing reoccurring time deviations, despite automatic synchronization (I don't know how often this is executed), you could have this command executed by the cron daemon, e.g. by adding it to the file /etc/crontab. The following line will cause the command to be executed at the 0. minute every hour:

0 *    * * *   root    /usr/sbin/ntpdate ntp.ubuntu.com

If you want to use another time interval, consult the manpage crontab(5).


PS: If the time is wrong each time you boot your computer, it is most likely caused by a failing CMOS battery; you may want to look for a replacement.

  • @kos Actually ntpdate daemon can be seen running during the installation of Ubuntu (I know because mine times out) but then Ubiquity uninstalls it as part of post-installation process. – Ashhar Hasan Dec 7 '15 at 21:45
  • 3
    @AshharHasan ntpd and ntpdate are two different programs from two different packages. – s3lph Dec 7 '15 at 21:49
  • @AshharHasan What the_seppi said, I think you're confusing the two, or referring to a previous Ubuntu release. I'm on an almost fresh installation of 15.10 and there's no ntpdate package nor ntpdate executable installed. – kos Dec 7 '15 at 21:51
  • I also agree that ntpdate is not available by default. @the_Seppi Thanks for telling me that. I felt that ntpd was the daemon for ntpdate. Learnt something today. ;) – Ashhar Hasan Dec 7 '15 at 22:29
  • ntpdate is deprecated in favor of tlsdate for end-user machines that don't need to run the full ntp package. – tgharold Jul 11 '16 at 2:00