Skip to main content
Topic: ntpd issue (Read 1327 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

ntpd issue

In response to accidental deletion by alium no problem. In response to phoenix_king_rus's suggestion to use ntpdate that actually works.  Is the startup of ntpd just being slow
Code: [Select]
# sv status ntpd
down: ntpd: 263629s, normally up
root@pikat:/var/log
# date 05051000
Wed  5 May 10:00:00 BST 2021
root@pikat:/var/log
# sv start ntpd
ok: run: ntpd: (pid 1688) 0s
root@pikat:/var/log
# date
Wed  5 May 10:00:34 BST 2021
root@pikat:/var/log
# sleep 60 && date
Wed  5 May 10:02:01 BST 2021
root@pikat:/var/log
# sv stop ntpd
ok: down: ntpd: 0s, normally up
root@pikat:/var/log
# ntpdate 0.uk.pool.ntp.org
 8 May 11:18:36 ntpdate[1730]: step time server 129.250.35.251 offset +263719.241482 sec
root@pikat:/var/log
# date
Sat  8 May 11:18:42 BST 2021
so it seems ntpdate works, but ntpd doesn't when started normally. I think the problem is that a recent runit world change has caused a change in sv/ntpd/run. I think that the run for ntpd needs to look like this

Code: [Select]
#!/bin/sh
# Thanks to replabrobin for the network check!
[ "$(ip route | awk '/^default/{print ($3!="")+($5!="")}')" = "2" ] || exit 1
ntpd -q -g -u ntp:ntp | logger 2>&1
exec ntpd -u ntp:ntp -n | logger 2>&1
at least when no rtc device keeps the clock in time.

 

Re: ARMTIX: ntpd issue

Reply #1
In response to accidental deletion by alium no problem. In response to phoenix_king_rus's suggestion to use ntpdate that actually works.  Is the startup of ntpd just being slow
Code: [Select]
# sv status ntpd
down: ntpd: 263629s, normally up
root@pikat:/var/log
# date 05051000
Wed  5 May 10:00:00 BST 2021
root@pikat:/var/log
# sv start ntpd
ok: run: ntpd: (pid 1688) 0s
root@pikat:/var/log
# date
Wed  5 May 10:00:34 BST 2021
root@pikat:/var/log
# sleep 60 && date
Wed  5 May 10:02:01 BST 2021
root@pikat:/var/log
# sv stop ntpd
ok: down: ntpd: 0s, normally up
root@pikat:/var/log
# ntpdate 0.uk.pool.ntp.org
 8 May 11:18:36 ntpdate[1730]: step time server 129.250.35.251 offset +263719.241482 sec
root@pikat:/var/log
# date
Sat  8 May 11:18:42 BST 2021
so it seems ntpdate works, but ntpd doesn't when started normally. I think the problem is that a recent runit world change has caused a change in sv/ntpd/run. I think that the run for ntpd needs to look like this

Code: [Select]
#!/bin/sh
# Thanks to replabrobin for the network check!
[ "$(ip route | awk '/^default/{print ($3!="")+($5!="")}')" = "2" ] || exit 1
ntpd -q -g -u ntp:ntp | logger 2>&1
exec ntpd -u ntp:ntp -n | logger 2>&1
at least when no rtc device keeps the clock in time.

I would suggest a different approach: ntpd can have a conf file with
Code: [Select]
NTPDATE_SERVER=""
and run script using this variable as follows:
Code: [Select]
[ -n $NTPDATE_SERVER ] && ntpdate $NTPDATE_SERVER || exit 1
(i didn't test it in this exact form, currently i keep a hard-coded server in my local ntpd script)
ARMtix