juppiter89
Posts: 91
Joined: Fri Jan 04, 2013 10:50 pm

Clock not syncing

Wed Sep 25, 2013 1:20 pm

Hi guys, I installed the last Raspbian version, dated 2013-09-10 (manual installation, without NOOBS or whatever), but I noticed that now the clock is not synchronized with the network. In the oldest versions it worked flawlessy.
What can it be? Thank you.

juppiter89
Posts: 91
Joined: Fri Jan 04, 2013 10:50 pm

Re: Clock not syncing

Wed Sep 25, 2013 1:52 pm

Here we go:

Code: Select all

Sep 10 18:19:17 raspberrypi ntpd[2007]: ntpd [email protected] Fri May 18 20:30:57 UTC 2012 (1)
Sep 10 18:19:17 raspberrypi ntpd[2015]: proto: precision = 1.000 usec
Sep 10 18:19:17 raspberrypi ntpd[2015]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
Sep 10 18:19:17 raspberrypi ntpd[2015]: Listen normally on 1 lo 127.0.0.1 UDP 123
Sep 10 18:19:17 raspberrypi ntpd[2015]: peers refreshed
Sep 10 18:19:17 raspberrypi ntpd[2015]: Listening on routing socket on fd #18 for interface updates
Sep 10 18:19:17 raspberrypi ntpd[2015]: restrict: error in address '::' on line 38. Ignoring...
Sep 10 18:19:17 raspberrypi ntpd[2015]: restrict: error in address '::1' on line 42. Ignoring...
Sep 10 18:19:17 raspberrypi ntpd[2015]: Deferring DNS for 0.debian.pool.ntp.org 1
Sep 10 18:19:17 raspberrypi ntpd[2015]: Deferring DNS for 1.debian.pool.ntp.org 1
Sep 10 18:19:17 raspberrypi ntpd[2015]: Deferring DNS for 2.debian.pool.ntp.org 1
Sep 10 18:19:17 raspberrypi ntpd[2015]: Deferring DNS for 3.debian.pool.ntp.org 1
Sep 10 18:19:17 raspberrypi ntpd[2025]: signal_no_reset: signal 17 had flags 4000000
Sep 10 18:19:17 raspberrypi ntpd[2015]: Cannot find user ID 102
Sep 10 18:19:19 raspberrypi ntpd_intres[2025]: parent died before we finished, exiting

User avatar
rpdom
Posts: 15604
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Clock not syncing

Wed Sep 25, 2013 3:18 pm

User ID 102 on Raspbian is usally the "ntp" user. Have you edited your /etc/passwd file, or deleted any users?

You should be able to see the entry like this

Code: Select all

[email protected]:~$ grep 102 /etc/passwd
ntp:x:102:103::/home/ntp:/bin/false
[email protected]:~$
If that line doesn't show, try

Code: Select all

sudo apt-get --reinstall install ntp
and see if that fixes it.

juppiter89
Posts: 91
Joined: Fri Jan 04, 2013 10:50 pm

Re: Clock not syncing

Wed Sep 25, 2013 4:58 pm

I have edited nothing, it's a standard installation.
I get:

Code: Select all

ntp:x:102:104::/home/ntp:/bin/false
EDIT: I just tried to reformat the SD and reinstall from scratch, but the clock still does not sync :?

dirkman
Posts: 17
Joined: Thu Sep 26, 2013 2:07 am
Location: Perth, Western Australia
Contact: Website

Re: Clock not syncing

Thu Sep 26, 2013 2:10 am

I have the same issue with my Pi, ntpd was not installed by default it seemed. I also tried ntpdate w/o success. I reinstalled ntpd as suggested but still no sync.

dirkman
Posts: 17
Joined: Thu Sep 26, 2013 2:07 am
Location: Perth, Western Australia
Contact: Website

Re: Clock not syncing

Thu Sep 26, 2013 2:14 am

also running "sudo ntpd -q" returns nothing, odd

juppiter89
Posts: 91
Joined: Fri Jan 04, 2013 10:50 pm

Re: Clock not syncing

Thu Sep 26, 2013 9:12 am

Well, I think is a problem of this Raspbian build... :?

FM81
Posts: 518
Joined: Wed Apr 17, 2013 4:33 pm

Re: Clock not syncing

Thu Sep 26, 2013 10:00 am

Please post contents of your '/etc/ntp.conf'!

MfG, FM_81
A: What does the command 'cat /dev/urandom', can you tell me please?
B: Yeah, that's very simple: It feeds your cat with radioactive material!

juppiter89
Posts: 91
Joined: Fri Jan 04, 2013 10:50 pm

Re: Clock not syncing

Thu Sep 26, 2013 10:14 am

Code: Select all

# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help

driftfile /var/lib/ntp/ntp.drift


# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/

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


# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example

# pool.ntp.org maps to about 1000 low-stratum NTP servers.  Your server will
# pick a different set every time it starts up.  Please consider joining the
# pool: <http://www.pool.ntp.org/join.html>
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


# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end

# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust


# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255

# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines.  Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient

FM81
Posts: 518
Joined: Wed Apr 17, 2013 4:33 pm

Re: Clock not syncing

Thu Sep 26, 2013 11:14 am

And you get an answer if you

Code: Select all

ping 0.debian.pool.ntp.org
(or one of the other three)?

In normal way it should listen to a real interface, like

Code: Select all

22 Sep 20:58:33 ntpd[1734]: Listen normally on 2 eth0 192.168.0.11 UDP 123
instead at loopback-interface (entry from your first logfile)

Code: Select all

Sep 10 18:19:17 raspberrypi ntpd[2015]: Listen normally on 1 lo 127.0.0.1 UDP 123
MfG, FM_81
A: What does the command 'cat /dev/urandom', can you tell me please?
B: Yeah, that's very simple: It feeds your cat with radioactive material!

juppiter89
Posts: 91
Joined: Fri Jan 04, 2013 10:50 pm

Re: Clock not syncing

Thu Sep 26, 2013 11:19 am

Yes, ping works fine.

FM81
Posts: 518
Joined: Wed Apr 17, 2013 4:33 pm

Re: Clock not syncing

Thu Sep 26, 2013 11:24 am

juppiter89 wrote:Yes, ping works fine.
OK, good ideas are out now; let's use the bad ones yet: What happens, if you comment out

Code: Select all

#restrict -6 default kod notrap nomodify nopeer noquery
and restart the ntp-daemon?
MfG, FM_81
A: What does the command 'cat /dev/urandom', can you tell me please?
B: Yeah, that's very simple: It feeds your cat with radioactive material!

juppiter89
Posts: 91
Joined: Fri Jan 04, 2013 10:50 pm

Re: Clock not syncing

Thu Sep 26, 2013 11:45 am

Not working, same logs.
However, I think the trouble is around "Cannot find user ID 102".

User avatar
jojopi
Posts: 3089
Joined: Tue Oct 11, 2011 8:38 pm

Re: Clock not syncing

Thu Sep 26, 2013 3:51 pm

juppiter89 wrote:However, I think the trouble is around "Cannot find user ID 102".
You are right—that error is fatal. It indicates that getpwuid(102) returned NULL¹. But we know that the passwd entry does in fact exist, because the init script that started ntpd used getpwnam("ntp") to obtain the number 102 in the first place.

The only situation I can find where one works and the other fails is if the permissions are wrong on /etc/passwd (should be 0644). This does not seem especially likely.

It is a shame that ntpd does not tell us what errno was set to. You could try "sudo strace -fs80 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 102:104" and see if you can spot the last thing that fails before the message is logged.

¹ (Or, implausibly, that strtoul() on the string "102" returned a number other than 102.)

juppiter89
Posts: 91
Joined: Fri Jan 04, 2013 10:50 pm

Re: Clock not syncing

Thu Sep 26, 2013 4:47 pm

Well, I get in the end of backtrace this:

Code: Select all

open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=58513, ...}) = 0
mmap2(NULL, 58513, PROT_READ, MAP_PRIVATE, 4, 0) = 0xb6f71000
close(4)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libnss_compat.so.2", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)
open("/lib/arm-linux-gnueabihf/libnss_compat.so.2", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)
open("/usr/lib/arm-linux-gnueabihf/libnss_compat.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib/libnss_compat.so.2", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)
open("/usr/lib/libnss_compat.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
munmap(0xb6f71000, 58513)               = 0
gettimeofday({1378885021, 903077}, NULL) = 0
send(3, "<27>Sep 11 09:37:01 ntpd[2912]: Cannot find user ID 102", 55, MSG_NOSIGNAL) = 55
exit_group(-1)                          = ?
Process 2912 detached
It seems that some packeges are missing and some permissions wrong.

EDIT: Oh yeah, I found a workaround, really not the best solution but it works :lol:
Two libraries (or their symlinks) were missing, I don't know why, so I did:

Code: Select all

sudo cp /lib/arm-linux-gnueabihf/libnss_compat.so.2 /usr/lib/
sudo cp /lib/arm-linux-gnueabihf/libnsl.so.1 /usr/lib/
If anyone knows any better solution, it is well accepted. Thanks to all who helped me. :D

User avatar
rpdom
Posts: 15604
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Clock not syncing

Thu Sep 26, 2013 5:39 pm

I think you are right. Something is wrong.

Code: Select all

open("/lib/arm-linux-gnueabihf/libnss_compat.so.2", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)
I have that file

Code: Select all

[email protected]:~$ ls -l /lib/arm-linux-gnueabihf/libnss_compat.so.2
lrwxrwxrwx 1 root root 21 Feb 23  2013 /lib/arm-linux-gnueabihf/libnss_compat.so.2 -> libnss_compat-2.13.so
[email protected]:~$ cd /lib/arm-linux-gnueabihf/
[email protected]:/lib/arm-linux-gnueabihf$ ls -l libnss_compat-2.13.so
-rw-r--r-- 1 root root 26484 Feb 23  2013 libnss_compat-2.13.so
[email protected]:/lib/arm-linux-gnueabihf$
The files are part of the libc6 package which your Pi with Raspbian would not work without.

Possibly some filesystem corruption?

User avatar
jojopi
Posts: 3089
Joined: Tue Oct 11, 2011 8:38 pm

Re: Clock not syncing

Thu Sep 26, 2013 5:40 pm

Those .so files are parts of the C library that deal with various types of system database. They should all be in /lib/arm-linux-gnueabihf/ and world-readable. It is normal that the system falls back to looking in other places. Copying the files fixed the permissions (of the copies).

You should probably reinstall the C library with "sudo apt-get install --reinstall libc6". However, what caused the original problem could have caused corruption to other files or permissions as well, so it may be safer to write a fresh image.

ripat
Posts: 191
Joined: Tue Jul 31, 2012 11:51 am
Location: Belgium

Re: Clock not syncing

Fri Sep 27, 2013 7:35 am

I am new to RPi but a long time Debian user and just had the same time sync problem on my recently installed RPi. Here is what I did to get it working properly the Debian way:
  • install the ntpdate package from the repo.
  • In the /etc/default/ntpdate.conf file set NTPDATE_USE_NTP_CONF=no
  • To avoid socket conflict, remove (purge) the ntp package. Furthermore, you don't really need that ntpd daemon to run permanently unless you time sync other hosts from your lan on your RPi. And it uses some memory (0,8% on my RPi) .
  • run $sudo ntpdate-debian to check if the update is working. It usually take about 10 sec. to sync. Don't jump on the ctrl-c key if you think it stalled!
  • The ntpdate-debian will run every time an interface is brought up (/etc/network/if-up.d/ntpdate).
  • If you want ntpdate-debian to be run more regularly, use cron or drop a script running ntpdate-debian in one of the /etc/cron.hourly|daily|weekly directories
May not be the only way to sync the time but this one works and is lightweight (no daemon)
Using Linux command line usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

gigabitfx
Posts: 1
Joined: Thu Aug 14, 2014 3:53 pm

Re: Clock not syncing

Thu Aug 14, 2014 4:05 pm

Commenting out the ipv6 stuff in /etc/ntp.conf made mine start working. Seems ipv6 is disabled by default in raspbian, which is fine by me, but having time synced is more important.
The below modification alone will make it work.

Code: Select all

#restrict -6 default kod notrap nomodify nopeer noquery
The following modification in addition will keep the log more clean

Code: Select all

#restrict ::1

Return to “Troubleshooting”