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?

Peter Mortensen
  • 2,004
  • 2
  • 15
  • 18
Pygmalion
  • 458
  • 2
  • 7
  • 25

8 Answers8

12
sudo sntp -s time.google.com

This worked for me.

goobering
  • 10,750
  • 4
  • 40
  • 64
Nicky
  • 121
  • 1
  • 2
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

nmur
  • 103
  • 2
Shamshu
  • 101
  • 1
  • 3
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!

Peter Mortensen
  • 2,004
  • 2
  • 15
  • 18
Alexey Vesnin
  • 926
  • 10
  • 17
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
mwd27
  • 351
  • 2
  • 2
3

The following command will surely work

sudo date -s"Sep 11 12:50"
satven
  • 31
  • 1
2

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

sudo sntp -s 0.debian.pool.ntp.prg
Ghanima
  • 15,958
  • 17
  • 65
  • 125
David
  • 21
  • 1
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.

Lightsout
  • 429
  • 1
  • 5
  • 20
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.

Scott H
  • 11
  • 1