[Bug 581193] [NEW] ntp init script fails to start ntpd
Dyna
dyn_ares at yahoo.com
Sun May 16 08:06:01 BST 2010
Public bug reported:
Binary package hint: ntp
In /etc/init.d/ntp you sync with the ntp servers with this line:
/usr/sbin/ntpdate -s -b $NTPDATE_OPTIONS $tickers &>/dev/null
After that the script starts ntpd with this line
start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --startas
$DAEMON -- -p $PIDFILE -u $UGID $NTPD_OPTS
What happens is that. ntp will not start since port 123 (ntp) is already in use.
/* from strace:
bind(16, {sa_family=AF_INET, sin_port=htons(123), sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EADDRINUSE (Address already in use)
*/
The reason is that, ntpdate is running in the background and if it
doesn't sync fast it will still use port 123 when ntp is trying to start
a few lines down the script.
Here is a patch :) -- and yes you have to strart ntpdate in the
foreground otherwise you have a race!!
--- ntp.old 2010-05-16 08:04:53.000000000 +0100
+++ ntp 2010-05-16 07:59:44.000000000 +0100
@@ -54,7 +54,7 @@
tickers=$(awk '$1=="peer"||$1=="server"{print $2}' /etc/ntp.conf | fgrep -v 127.127.1.0)
echo "Synchronizing with time server: "
- /usr/sbin/ntpdate -s -b $NTPDATE_OPTIONS $tickers &>/dev/null
+ /usr/sbin/ntpdate -s -b $NTPDATE_OPTIONS $tickers >/dev/null
log_daemon_msg "Starting NTP server" "ntpd"
Cheers Dyna
** Affects: ntp (Ubuntu)
Importance: Undecided
Status: New
--
ntp init script fails to start ntpd
https://bugs.launchpad.net/bugs/581193
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in ubuntu.
More information about the Ubuntu-server-bugs
mailing list