timedate-ubuntu-16

I recently came across an issue where an Ubuntu 14.04 LTS server wasn’t syncing the time so the jitter and drifting of the time wasn’t correcting itself. This caused issues with some of the applications running on the server because the time would be off as much as 45 minutes after a week or two of uptime. When running the timedatectl command, I would see NTP Synchronized No as seen below:

Network time on: yes
NTP synchronized: no
RTC in local TZ: no

In my case, this appears to be caused by having both timedatectl and ntpdate installed. Since ntpdate is depreciated, I decided to uninstall it and fix the issues with timedatectl.

Uninstall ntpdate

To uninstall ntpdate, run the following command:

sudo apt-get remove ntpdate

Update NTP Time And Start Service

Run the following commands to stop the NTP service, update the time, and restart the service.

sudo service ntp stop
sudo ntpd -gq
sudo service ntp start

The -gq tells the ntp daemon to correct the time regardless of the offset (g) and exit immediately (q). In my case, the ntp service wasn’t even running because of a conflict with the previously installed ntpdate.

Set timedatectl To Use NTP Synchronization

Run the following command to tell timedatectl to use NTP network-based time synchronization.

sudo timedatectl set-ntp true

Verify timedatectl Has NTP Synchronized Yes

Finally, run the timedatectl command again and verify that you have NTP Synchronized Yes as seen below:

NTP enabled: yes
NTP synchronized: yes

Set The NTP Service To Auto-Start

First, try running the following command:

sudo update-rc.d ntp defaults

This should add the service to the automatic startup system. But if you get:
System start/stop links for /etc/init.d/minidlna already exist.

Then run this command instead:

sudo update-rc.d ntp enable