ntpd doesn't start correctly
Garry T. Williams
gtwilliams at gmail.com
Wed Jun 21 10:52:23 UTC 2006
On Wednesday 21 June 2006 02:32, Rob Brown-Bayliss wrote:
> On 6/21/06, Ambrogio <fn050202 at flashnet.it> wrote:
> > I'm experiencing a bad behavior of ntp server.
>
> I have had some network probnlems lately, and noticed that if the
> network is not running before NTP starts it plays up a bit.
>
> It's not a fix, but hack as such, can you set things so that ntpd
> only starts when at home or your office? That way you know the
> network is running first? Perhjapse use a spare runlevel for the
> office/home and another for on the raod?
If you use NetworkManager, you can solve this problem.
The NetworkManagerDispatcher will run programs or scripts in response
to interface up/down events. One use of this is to start (or restart)
the ntpd when the interface transitions from down -> up and to stop
the ntpd when the interface transitions from up -> down. See
NetworkManagerDispatcher(1) for details.
Here's the script I run on on my laptop when an interface transitions
(/etc/NetworkManager/dispatcher.d/ntpd-script). I can't remember
where I got this, but the code is simple and straightforward. I
always have a happy ntpd as long as I have an interface up:
#!/bin/bash
#
# $Id: ntpd-script,v 1.1 2006/02/18 10:52:03 root Exp $
if [ -x /usr/bin/logger ]; then
LOGGER="/usr/bin/logger -s -p user.notice -t NetworkManagerDispatcher"
else
LOGGER=echo
fi
if [ ! -x /etc/init.d/ntpd ]; then
$LOGGER "init script /etc/init.d/ntpd missing or not executible"
return
fi
if [ -n $1 ] && [ $2 == "up" ]; then
if [ -f /var/run/ntpd.pid ]; then
$LOGGER "ntpd is running, restart"
/sbin/service ntpd restart
else
$LOGGER "ntpd is not running, start"
/sbin/service ntpd start
fi
fi
if [ -n $1 ] && [ $2 == "down" ] && [ -f /var/run/ntpd.pid ]; then
$LOGGER "ntpd is running, stop"
/sbin/service ntpd stop
fi
--
Garry T. Williams --- +1 678 656-4579
More information about the fedora-list
mailing list