2

Since my hardware (RasberryPi) does not have a hardware-clock, each bootup warps us back to the 1970's, so I use NTP. The gateway on the network I am on provides an NTP-Server service.

my /etc/ntp.conf looks like the follwing (commented lines ommitted)

server 192.168.170.254 //gateway that hosts the service
driftfile /var/lib/ntp/ntp.drift

/etc/profile:

[connect wifi...]
timeout 15 ntpd -q -g //forces update so I have a time to work with, times out so I don't get a total hang if it doesn't work
systemctl start ntpd.service //in hopes that I will work at some point and to keep it in sync
date //see if it worked
[start main program...]

Am I missing something?

Edit
Output of ntpd -q:

DEC 31 17:00:43 alarmpi ntpd[349]: ntpd [email protected] Wed Jul  2 03:23:39 UTC 2014 (1): Starting
DEC 31 17:00:43 alarmpi ntpd[349]: Command line: /usr/bin/ntpd -q
DEC 31 17:00:43 alarmpi ntpd[349]: proto: precision = 3000 usec (-18)
DEC 31 17:00:43 alarmpi ntpd[349]: Listen and drop on 0 v4wildcard 0.0.0.0:123
DEC 31 17:00:43 alarmpi ntpd[349]: Listen normally on 1 lo 127.0.0.1:123
DEC 31 17:00:43 alarmpi ntpd[349]: Listen normally on 2 wlan0 192.168.170.100:123
DEC 31 17:00:43 alarmpi ntpd[349]: Listening on routing socket on fd #19 for interface updates
#hangs here till interrupted

Output of systemctl status ntpd:

* ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled)
Active: active (running) since Wed 1969-12-31 17:00:43 MST, 16s ago
Process: 332 ExecStart=/usr/bin/ntpd -g -u ntp:ntp -p /run/ntpd.pid (code=exited, status=0/SUCCESS)
Main PID: 335 (ntpd)
CGroup: /system.slice/ntpd.service
        `-335 /usr/bin/ntpd -g -u ntp:ntp -p /run/ntpd.pid

DEC 31 17:00:43 alarmpi ntpd[332]: ntpd [email protected] Wed Jul  2 03:23:39 UTC 2014 (1): Starting
DEC 31 17:00:43 alarmpi ntpd[332]: Command line: /usr/bin/ntpd -g -u ntp:ntp -q /run/ntpd.pid
DEC 31 17:00:43 alarmpi systemd[1]: PID file /run/ntpd.pid not readable (yet?) after start.
DEC 31 17:00:43 alarmpi ntpd[335]: proto: precision = 3000 usec (-18)
DEC 31 17:00:43 alarmpi ntpd[335]: Listen and drop on 0 v4wildcard 0.0.0.0:123
DEC 31 17:00:43 alarmpi ntpd[335]: Listen normally on 1 lo 127.0.0.1:123
DEC 31 17:00:43 alarmpi ntpd[335]: Listen normally on 2 wlan0 192.168.170.100:123
DEC 31 17:00:43 alarmpi ntpd[335]: Listening on routing socket on fd #19 for interface updates
DEC 31 17:00:43 alarmpi systemd[1]: Started Network Time Service
10
  • 1
    Where is the actual problem? In the direct call to ntpd, In the ntpd that was started as a service or do you just know that the output of date is wrong? What is the output of the call to ntpd and of systemctl status ntpd and ntpq -p?
    – Wieland
    Aug 2, 2014 at 9:36
  • @Wieland I can't tell. All I know is that neither works, since time doesn't get updated
    – Mark
    Aug 2, 2014 at 11:32
  • @Mark: Please attach the output of systemctl status ntpd and ntpq -p. Aug 2, 2014 at 15:36
  • @MartinSchröder done.
    – Mark
    Aug 4, 2014 at 5:12
  • 1
    No: I would sync to a pool server and see if that is more accurate. As I said in my other answer, systemd-{networkd,timesyncd} is a better option for the Pi.
    – jasonwryan
    Aug 4, 2014 at 5:37

1 Answer 1

1

@asonwryan's answer to another question provides a good solution to this problem. Hardware problems (lack of Real Time Clock) make this a bit difficult.

Give the RaspberryPi's lack of a RTC, I would suggest that you ensure that you use a tool that can store the last time to disk and then references that at boot time to pull the clock out of the dawn of UNIX time.

Using a combination of systemd-timesyncd, with an optional configuration file for your preferred time servers in /etc/systemd/timesyncd.conf, and systemd-networkd will bring your network up swiftly at boot and correct any drift in your clock as early as practicably possible. The daemon will then sync your clock at periodic intervals (around every 30 minutes).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .