11

I bought a Raspberry Pi 3 approximately two months ago, and since then time has never updated. Details:

  1. The operating system is a fresh installation of Raspbian Jessie (4.1.19-v7+).
  2. The Internet connection is via native Wi-Fi and no other problem with communication.
  3. No firewall problems as time update works like a charm on a Windows machine on the same LAN.
  4. Time zone is properly set.

I first started with nptdate. When I tried forcing update,

sudo /etc/init.d/ntp stop
sudo ntpd -q -g
sudo /etc/init.d/ntp start

the terminal froze at the second command. The last message in /var/log/syslog was:

Listening on routing socket on fd #22 for interface updates

/etc/ntp.conf contents:

driftfile /var/lib/ntp/ntp.drift

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

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

restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery

restrict 127.0.0.1
restrict ::1

It seems to me that the ntp package has a problem. How do I set up time update, as my Raspberry is turned on only during the day and time lag accumulates during the night?

12
  • 1
    What distribution are your using? These ancient links have nothing to do with current Raspbian. How long do you wait after boot? What are you doing to confirm "time won't update"?
    – Milliways
    May 18, 2016 at 9:46
  • It is Raspbian if you are asking that. No matter how long I wait it does not update. I use "date" command and watch clock command in the corner.
    – Pygmalion
    May 18, 2016 at 9:48
  • ntpd changed at some point in the past few years to make it harder for the user to force a change. Considering how simplistic its purpose, it is one of the absolute worst designed, most obtuse apps of all time. Someone should just write a basic, client only implementation for standalone end-user systems. It could not take more than a day, including reading the RFCs. I feel for you. I hate that thing (except it generally works for me so I'm not bothered...). Good luck.
    – goldilocks
    May 18, 2016 at 10:56
  • That said, I think you could add a more detailed explanation of what exactly happens. It certainly squawks a lot when it cannot connect to a server, and that stuff will be in syslog. Have a look at sudo grep ntp /var/log/syslog or, after booting, journalctl | grep ntp.
    – goldilocks
    May 18, 2016 at 11:00
  • @goldilocks sudo grep ntp /var/log/syslog returns bunch of bad peer from pool x.debian.pool.ntp.org errors. After restarting journald | grep ntp returns bash: journald: command not found and sudo grep ntp /var/log/syslog returns bunch of can't find host x.debian.pool.ntp.org: name or service not known errors and no servers can be used, exiting
    – Pygmalion
    May 18, 2016 at 11:20

8 Answers 8

6

You need to try to update time via a USB Wi-Fi dongle. If it will work fine, then use tcpdump and take a look how the packet is handled on both sides: On Raspberry Pi 3 and the Wi-Fi AP it connects to.

The internal Wi-Fi of Raspberry Pi 3 is used to be losing packets silently as far as I know.

How /etc/network/interfaces should look like:

# Wired adapter #1
auto eth0
    iface eth0 inet static
    address 192.168.0.3
    netmask 255.255.255.0
    gateway 192.168.0.1
    dns-servers 8.8.8.8,8.8.4.4
    post-up /usr/sbin/ntpdate -4 1.2.3.4

Don't forget leading spaces!

3
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Ghanima
    May 22, 2016 at 18:48
  • I found solution how to "repair" ntpd on this thread: raspberrypi.org/forums/viewtopic.php?f=28&t=141454. I still do not know how to make it automatically at booting the RPi3.
    – Pygmalion
    Jun 1, 2016 at 15:14
  • @Pygmalion as I said before - ntpD=NTP Daemon - is not required for a simple host time setting... It is maid for distributing time through network, i.e. if you have a multiple nodes, you need it for sure. But for a single endpoint time setting a ntpdate tool is made. It is even separated in ntp source tree itself Jun 13, 2016 at 18:28
12
sudo sntp -s time.google.com

This worked for me.

9

I tried several ways with ntp, chrony... Finally fixed with the following method.

Fetch date from any renowned website like google to set your machine time at every boot.

  1. Open rc.local file

    sudo nano /etc/rc.local

  2. Add following line to the rc.local file

    sudo date -s "$(wget -qSO- --max-redirect=0 www.google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"

  3. Reboot the Rpi

    sudo reboot

2
  • I liked the solution. It worked but I would be happy with ntp solution. I tried them but I was not able to get through that.
    – Varad A G
    Aug 14, 2017 at 6:59
  • I can understand this desperation - this is exaclty what I also have done on some ocasions (date from HTTP header), but now I'm in a closed network with no internet access, and no HTTP servers, just a NTP server. Sep 14, 2017 at 21:01
4

If you set the Time Zone in raspi-config the Raspberry Pi will automatically update the time on boot, if connected to the internet.

  1. sudo raspi-config
  2. Select Internationalisation Options
  3. Select I2 Change Timezone
  4. Select your Geographical Area
  5. Select your nearest City
  6. Select Finish
  7. Select Yes to reboot now
4
  • Of course I set time zone the very first day.
    – Pygmalion
    May 21, 2016 at 20:07
  • 1
    I also set the time zone the very first day, but my Pi recently stopped updating the time on reboot, exactly like the problem you are having. I re-ran raspi-config yesterday and the time has updated correctly on every reboot since, even if I've left the power unplugged for a while. I suggest you give it a try? Let me know how you get on...
    – mwd27
    May 21, 2016 at 20:13
  • I am sorry. I did as you suggested, but it failed.
    – Pygmalion
    May 22, 2016 at 6:36
  • Oh, that's a shame. I'll keep thinking...
    – mwd27
    May 22, 2016 at 12:55
3

The following command will surely work

sudo date -s"Sep 11 12:50"
1
  • 1
    Thank you for your answer. I think the question is about automatic updating, using NTP, though, and your answer seems to be about one-time setting of the clock.
    – Bex
    Sep 11, 2018 at 9:19
2

I found that using the following worked as a one off via WiFi.

sudo sntp -s 0.debian.pool.ntp.prg
1

In Application Menu/Preferences/Raspberry Pi Configuration I went to the Localisation tab and selected values for Set Locale, Set Timezone and Set WiFi Country.

Clicked OK and Time is now correct.

1

For me I had to wait a bit for some reason it didn't set the correct time right away. This is after I set correct time zone, had internet access enabled and rebooted.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.