3

I'm using Ubuntu Mate 15.10 on a F.Siemens laptop. I'm facing a time drift issue that I'd need some help with.

The time drifts by as much as 15 minutes in a 2-3 hour span. Forcing an update (with sudo ntpdate after stopping then restarting the service) works, but drift eventually returns. I noticed that at some point the clock corrected itself, which means npt does at some point run. But I'm a bit puzzled about its frequency, because on some occasions it seems to correct the time once in, say, two hours, while on others many hours can pass by without any correction.

My question is: which file/setting do I have to edit in order to a) check that the service is indeed active; b) adjust the frequency.

9
  • Thanks for the input, but #2 and #3 are too complex to follow (I'm not even sure they are relevant), and #1 doesn't seem to have any effect. I edited /etc/systemd/timesyncd.conf, but I see no change
    – user487464
    Jul 10, 2016 at 11:19
  • What is the output of timedatectl status ? Does it say "Network time on: Yes" and "NTP synchronized: yes"?
    – mchid
    Jul 10, 2016 at 11:34
  • It does say that, yes. The time is still off
    – user487464
    Jul 10, 2016 at 12:46
  • Is it fixed when you run systemctl restart systemd-timesyncd
    – mchid
    Jul 10, 2016 at 12:50

1 Answer 1

2

Unless you reboot your system, I believe the system is set to sync your time only once every 24 hours.

You can run a cron job to query the ntp server to keep your time in sync more often.

Run the following command to edit your cron jobs:

sudo crontab -e

If the system asks, choose nano as the editor.

Then, scroll to the end of the file and enter the following line to set the time every 30 minutes:

*/30 * * * * /usr/sbin/ntpdate ntp.ubuntu.com

Press CTRL + o and then press ENTER to save the file. Press CTRL + x to exit nano.


If that doesn't work, you could do this cronjob instead:

*/30 * * * * /bin/systemctl restart systemd-timesyncd

You can adjust the time schedule in units of 10 so you could set it to 10 or 40 or 60 or whatever instead of 30 by editing that value set.

It may not be necessary, but you can restart cron just for good measure by executing the following command:

 sudo service cron restart

EDIT

In order to use systemd-timesyncd, run the following commands:

sudo apt-get purge ntp openntp
sudo systemctl enable systemd-timesyncd
sudo systemctl restart systemd-timesyncd

Finally, to check the status:

systemctl status systemd-timesyncd
5
  • Checking with systemctl status systemd-timesyncd I get the following error: Condition: start condition failed at Sun 2016-07-10 18:54:58 EEST; 8min ago ConditionFileIsExecutable=!/usr/sbin/ntpd was not met
    – user487464
    Jul 10, 2016 at 16:04
  • @DigitalDracula This is helpful. I see. You can't have ntpd and systemd-timesyncd. I have provided alternative instructions, however, if the alternative instructions above don't work, I will provide instructions on how to remove ntpd and use systemd-timesyncd instead of ntpd. This is what I do and it seems to work well.
    – mchid
    Jul 10, 2016 at 16:13
  • The alternative instructions ´*/30 * * * * /usr/sbin/ntpdate ntp.ubuntu.com´ don't seem to work either - I tested it forcing it to run every minute, but ´ntpdate -q´ shows increasing drift. Apparently ntpd has to be removed?
    – user487464
    Jul 10, 2016 at 16:19
  • @DigitalDracula I will update the instructions.
    – mchid
    Jul 10, 2016 at 16:26
  • I removed ntpd and it now seems to be working. Thanks for your help, I'll mark this as resolved
    – user487464
    Jul 10, 2016 at 16:37

You must log in to answer this question.