3

The time and date of my pi with a clean install of raspbian running is very wrong. If I run date now, it tells me this: Thu May 7 01:39:43 2015. Neither the time or date is right.

I've tried to change the ntp servers, restart the time service, force sync, and now a clean reinstall, to no use.

I set time timezone to Oslo. Does anyone have any clue to what it could be?

ptf
  • 329
  • 1
  • 3
  • 10
  • 1
    Keep in mind the RasPi has no real time clock on board, so it if it needs to be aware of the actual time of day, you either need to connect to the internet every time power is restored or add a RTC to it. – Octopus Jul 17 '15 at 20:13
  • They use a "pool" of time servers that are 16 layers away from the atomic clock. To set it to Stratum 1 or 2, use time.nist.gov as described here: https://raspberrypi.stackexchange.com/questions/68811/how-do-i-set-raspbian-to-use-the-primary-time-server-time-nist-gov/68812 – SDsolar Sep 25 '17 at 07:16

1 Answers1

6

Did you

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

? (as already pointed out here.)

Output should look like this:

[ ok ] Stopping NTP server: ntpd.
ntpd: time slew +0.001411s
[ ok ] Starting NTP server: ntpd.

Note that it can be slow:

time ntpd -gq
ntpd: time slew -0.007043s

real    0m7.063s
user    0m0.040s
sys 0m0.020s

You can also double check you are not talking to nothing;

grep -P "^server" /etc/ntp.conf 
server 0.debian.pool.ntp.org iburst
server 1.debian.pool.ntp.org iburst
server 2.debian.pool.ntp.org iburst
server 3.debian.pool.ntp.org iburst
ping -c 1 0.debian.pool.ntp.org
PING 0.debian.pool.ntp.org (192.99.10.37) 56(84) bytes of data.
64 bytes from sexi.fawong.com (192.99.10.37): icmp_req=1 ttl=55 time=32.8 ms

--- 0.debian.pool.ntp.org ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 32.890/32.890/32.890/0.000 ms
user1133275
  • 2,167
  • 12
  • 30
  • I tried it yesterday, and again now. It seems the `sudo ntpd -gq' command is just hanging and not completing. Forgot about that. Seems like it isn't connecting to the servers or something. – ptf Jul 17 '15 at 20:00
  • What do you do if you get nothing back? – AdamMc331 Feb 15 '16 at 23:25
  • Pinging 0.debian.pool... never got a response. It looks like the university's network that I was on had port 123 blocked and that's why. Still haven't figured out a workaround though. Any ideas? – AdamMc331 Feb 17 '16 at 05:55
  • @McAdam331 what's the output of "dig 0.debian.pool.ntp.org" and "sudo nmap -p 123 0.debian.pool.ntp.org" ? also http://support.ntp.org/bin/view/Support/TroubleshootingNTP#Section_9.8. – user1133275 Feb 17 '16 at 15:35
  • I don't know which of the suggestions, but doing this fixed my Pi being approx. 50 mins late. – esbenr Dec 03 '16 at 19:10
  • same here sudo ntpd -gq hangs forever – dss Jan 08 '17 at 00:55
  • @dss edit /etc/ntp.conf to point to an accessible server. – user1133275 Feb 27 '17 at 16:45