The Raspberry Pi lacks a hardware clock. How do I force NTPD to update date/time immediately after every boot?
I'm running Raspbian and the Raspberry Pi is connected using an Ethernet cable.
|
|
Do an ntpdate will run when an ethernet interface is brought up, and set the time from an ntp server (see /etc/default/ntpdate). If ntpd is running, ntpdate will do nothing, however ntpdate will run prior to ntpd at bootup - so this should work out to set the time at bootup as long as there's an ethernet connection. |
|||||||||||||||||
|
|
If your clock is way off, you may need to force ntp to sync by doing:
|
|||||||||||||||||||||
|
|
If you set the Time Zone in
|
|||||
|
|
It should already be updating the time. The NTPD server should start just after the swap file and before SSHD. Check your /etc/ntp.conf file to make sure it is configured. It should list at least one server. I use time.nrc.ca for my server. Manual page for ntp.conf is here: http://linux.die.net/man/5/ntp.conf |
|||
|
|
|
See forum post Time does not sync on Pi 3 and with official dongle. ntpd emits IP/UDP packets with the ToS field set to 0xc0. So that is quite similar to the other issue I (and many others) have with Raspberry Pi3 when operated over a Wi-Fi internal interface. As a workaround, add the command
to the file
before the exit 0 line. Next, reboot and check. |
|||||
|
|
After searching around, this method worked for me. As you know, the Raspberry Pi 3 has NTP disabled by default. So by just typing this, the NTP support will be enabled:
Check result with In case of warning, you may have to run |
|||||||||
|
|
My son's Rasberry Pi would not update the time out of the box and after trying all the suggestions above I could get it to update manually but not automatically. Finally after looking elsewhere as well without success, I found that the ntp.conf file that came with the Rasberry Pi had the following lines commented out:
I used
in the terminal to edit the ntp conf file to now be:
That solved the problem for us. It updates with both the WiFi and the ethernet cable. I don't know if it would update with WiFi without the change to rc.local suggested above, as by the time I found the solution above I had already made that change and I have not undone it. |
||||
|
|
|
I found the Note: make sure your timezone is set properly, which this tool can do as well. |
||||
|
|