3

I am using Raspberry PI Model B with Raspbian, installed by NOOBS, upgraded to the latest version. The NTP server is automatically started in the boot process.

When I boot my RPI, the time is always wrong — about 15 minutes in the past. Even if I wait for several hours, it's incorrect.

I run

/etc/init.d/ntp restart

manually and it sets the correct time within seconds, sometimes it needs two restarts.

I define several servers in the ntp.conf:

 server ntp1.t-online.de iburst prefer

 server 0.de.pool.ntp.org iburst
 server 1.de.pool.ntp.org iburst
 server 2.de.pool.ntp.org iburst
 server 3.de.pool.ntp.org iburst
 ...

Does anyone have an idea how to fix this?

Steve Robillard
  • 34,687
  • 17
  • 103
  • 109
Railsana
  • 151
  • 1
  • 1
  • 3
  • You will find those pools are Stratum 16. Instead, the most correct time is obtained from the master clock time: https://raspberrypi.stackexchange.com/questions/68811/how-do-i-set-raspbian-to-use-the-primary-time-server-time-nist-gov – SDsolar Oct 21 '17 at 20:29

3 Answers3

2

Are you using DHCP or static IP?

If you use DHCP then it will read /var/lib/ntp/ntp.conf.dhcp, not /etc/ntp.conf

If you use a static IP, remove /var/lib/ntp/ntp.conf.dhcp if it exist.

Either way, check if ntp is running after a reboot with ps aux | grep ntp If it is, then run ntpq -p to check if it has started to sync with the timeservers. This can take some time, sometime it needs 2-3 pulls, each taking about 60 seconds. Just rerun ntpq -p to see the status.

Sitron_NO
  • 186
  • 5
  • Thanks for your quick reply! I checked everything you wrote and I am using DHCP indeed, but my config file is definitely in /etc/ntp.conf. – Railsana Oct 23 '13 at 22:16
  • NTP is running after booting, but it doesn't connects to any servers. When I restart the NTP server, a log file is written and everything works fine. – Railsana Oct 23 '13 at 22:22
  • What is the output of ntpq -p after boot, and after restart of ntp? – Sitron_NO Oct 24 '13 at 06:24
  • Sorry, I only get this: localhost: timed out, nothing received ***Request timed out – Railsana Oct 27 '13 at 22:23
  • /var/log/ntpstats/peerstats is full of this: 56592 48260.308 192.53.103.108 9024 2201.124660904 0.224497746 7.937502637 0.000000954 – Railsana Oct 27 '13 at 22:26
0

I don't know what exactly went wrong, but something messed up the whole setup. I reinstalled Raspbian (via NOOBS) and all NTP settings worked fine again.

Railsana
  • 151
  • 1
  • 1
  • 3
-1

Here is a script that you can set to run on boot to fix your time

#!/bin/bash
#Visit www.timeapi.org to find the correct url for your timezone. Then 
replace the url in the first line

time=$(wget http://www.timeapi.org/utc/in+two+hours?format=%25d%20%25b%20%25Y%20%25I:%25M:%25S -q -O -)
echo "Time set to:"
sudo date -s "\`echo $time`"
RPiAwesomeness
  • 3,001
  • 4
  • 30
  • 51