-2

I use 14.04.1-Ubuntu. When execute date in command line, I get time which about 1 min different comparing Greenwich Mean Time or other source. I synchronized it using sudo ntpdate -s time.nist.gov few months ago but it jumped away again. Why does it happen? How to keep accurate time on Ubuntu continuously?

Justas
  • 221
  • 1
  • 6
  • 12

3 Answers3

6

How to keep accurate time on Ubuntu continuously?

By enabling the ntpd service and running it continuously.

I synchronized it using sudo ntpdate -s time.nist.gov few months ago but it jumped away again. Why does it happen?

The hardware clock in computer systems is simply not accurate enough.

HBruijn
  • 77,029
  • 24
  • 135
  • 201
6

Unfortunately Ubuntu hasn't added the disclaimer from NTP.org's ntp-4.2.*\html\ntpdate.html manual to Ubuntu's ntpdate(8) manpage, like for example FreeBSD has:

ntpdate - set the date and time via NTP

Disclaimer: This program has known bugs and deficiencies and nobody has volunteered to fix them in a long time. The good news is the functionality originally intended for this program is available in the ntpd and sntp programs.

See the Deprecating ntpdate topic in the NTP Support wiki for a thorough discussion and analysis of the issues. See the -q command line option in the ntpd - Network Time Protocol (NTP) daemon page and/or the sntp - Simple Network Time Protocol (SNTP) Client page. After a suitable period of mourning, the ntpdate program will be retired from this distribution.

If Ubuntu did so, you wouldn't even have to Google for this, not to mention asking it from Serverfault.

Esa Jokinen
  • 46,944
  • 3
  • 83
  • 129
  • 1
    To be fair, if you use `ntpd -q` only once in months, you won't yield better results. – Sven May 17 '17 at 08:13
  • 1
    True, but the point of this answer is that if this disclaimer was in the manpage, it would have directed OP to the right direction: `ntpdate` is deprecated, let's see what there is on `man ntpd`. Now it's not even in the "See also" section. I truly hope that reading `man ntpd` would enlighten the topic enough for not using merely `-q`. – Esa Jokinen May 17 '17 at 08:20
  • +1 for including the deprecation notice. – gxx Aug 18 '17 at 00:15
4
  1. Install ntp package sudo apt-get install ntp
  2. Edit /etc/ntp.conf for your neighbor ntp server sudo vi +/^server /etc/ntp.conf
  3. Reload ntp configuration sudo service ntp reload
  4. Check time sync status with ntpq -p. It takes some while for synchronized (*) status. sudo ntpq -p

Ref: Ubuntu 14.04 >> Ubuntu Server Guide >> Networking

https://help.ubuntu.com/14.04/serverguide/NTP.html

Justas
  • 221
  • 1
  • 6
  • 12
minish
  • 656
  • 3
  • 12