greetings,

As J Carerra mentioned, I was also having some problems with ntpd on Gutsy. I 
managed to solve my problems though, so I'm posting the solution
here in the hope that it might help someone else too.

My original analysis of the problem I was having with ntpd (which J Carerra has 
quoted here) was not quite correct (after hours of digging through init scripts 
I got slightly confused about which scripts run from rcS.d and which from 
rc2.d). The DHCP server in the building where I live doesn't provide NTP
servers, so I can't comment on what happens when your DHCP server does provide 
NTP servers.

I basically had two separate problems that were preventing ntpd and ntpdate 
from working properly:
* With NetworkManager managing my ethernet connection, ntpd was being started 
before eth0 was up, so ntpd couldn't associate with any other
   ntp servers. Then, when eth0 did come up, ntpdate couldn't run, because ntpd 
was already running.
* When I stopped NetworkManager from managing my ethernet connection by adding 
an entry for eth0 in /etc/network/interfaces, so that eth0 would be
   brought up by rcS.d/S40networking before ntpd was started by rc2.d/S23ntp 
everything worked most of the time. However /etc/network/if-up.d/ntpdate
   was running ntpdate in the background, which meant that every once in a 
while ntpdate would still be running by the time rc2.d/S23ntp tried to start
   ntpd, thus preventing ntpd from starting.

I managed to solve my ntp problems by writing a new script (which I'm attaching 
here) to replace /etc/network/if-up.d/ntpdate. This script works for me 
regardless of whether NetworkManager is managing my internet connection. If you 
want to try this solution, do the following:
* Leave the symlinks to /etc/init.d/ntp intact (the script won't start ntpd if 
it is disabled in the current runlevel)
* Deactivate (remove executable permissions from) /etc/network/if-up.d/ntpdate
* Put the new ntpd script at /etc/network/if-up.d/ntpd (and give it proper 
ownership and executable permissions)
* Enjoy (hopefully)

For every network interface that is brought up (except the loopback interface), 
this script:
* Stops ntpd (if it was running already)
* Runs /usr/bin/ntpdate-debian and
   - if ntpdate successfully sets the clock, also runs hwclock --systohc
* Starts ntpd again (but only if it is configured to start in the current 
runlevel)

Be warned though, that this script may cause misleading log entries
(particularly if NetworkManager is not managing your internet
connection) claiming that ntpd failed to start when it actually did
start. Unfortunately I don't really see a way of preventing this from
happening.

** Attachment added: "ntpd.sh"
   http://launchpadlibrarian.net/11066008/ntpd.sh

-- 
ntp brought up before network is ready; fails not resolve any ip or host names; 
ntp does not recover
https://bugs.launchpad.net/bugs/114505
You received this bug notification because you are a member of Ubuntu
Bugs, which is the bug contact for Ubuntu.

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to