[ntp:questions] Local clock question with dialup connection

Nigel Henry cave.dnb at tiscali.fr
Fri Apr 20 18:32:46 UTC 2007

On Friday 20 April 2007 14:50, Bob Beers wrote:
> On 4/19/07, Nigel Henry <cave.dnb at tiscali.fr> wrote:
> > The problems are with FC2. I know it's old, but I still receive all my
> > mail on it, and use it daily. I think what I really need is a script that
> > detects when an Internet connection is up and running, then starts ntpd.
> > I'm not too clever with scripts. I'll ask around, and see if some kind
> > hearted scripter can suggest something.
> How about something like this in a root cronjob:
> [[ $( ps axf | grep -c ntpd ) -eq 0 ]] && {
>     SRV=( $(grep ^server /etc/ntp.conf ) )
>     ping -c 3 -w 2 ${SRV[1]}
>     [[ $? -eq 0 ] && /usr/sbin/ntpd -g
> }
> HTH,
> -Bob

Hi Bob. Thanks for the script. I thought I'd just set it up in /usr/local/bin 
as an executable shell script at first to try it out.

Got a problem when trying to run it, with a command not found, and with a bit 
more work I get this.

 [root at localhost bin]# ntpstartnointernet
/usr/local/bin/ntpstartnointernet: line 6: syntax error in conditional 
/usr/local/bin/ntpstartnointernet: line 6: syntax error near `]'
/usr/local/bin/ntpstartnointernet: line 6: `    [[ $? -eq 0 ] 
&& /usr/local/bin/ntpd -g'
[root at localhost bin]#

any suggestions on a fix?

I changed /usr/sbin/ntpd to /usr/local/bin/ntpd as that is where the 4.2.4p0 
version is installed.

btw. ntpstartnointernet is the name of your script.


More information about the questions mailing list