# NTPD: Bug??

## bch

Hello,

After lots of playing around I have got ntpd working: synchs to stratum 2 server and synchs local winxp machines.

I did notice a problem: I dont know if this is a bug or a configuration error.

```

silent-srvr:> /etc/init.d/ntpd start          <---- works fine

silent-srvr:> /etc/init.d/ntpd stop           <---- stops fine

silent-srvr:> /etc/init.d/ntpd start       <--- fails!!!

```

Same results for:

```

silent-srvr:> /etc/init.d/ntpd restart       <----- stops fine then fails on restart

```

It appears the lock file is not removed when ntpd exits and then ntpd refuses to restart since it finds a lock file...

So to restart I need to :

```

silent-srvr:> /etc/init.d/ntpd stop

silent-srvr:> rm /var/run/ntpd.pid

silent-srvr:> /etc/init.d/ntpd start

```

Okay.... Whats up? Why is this not working...

In the init.d script it is using start-stop-daemon. I thought this was supposed to automaticly make and remove lock /pid files.

Thanks....

BRENT

----------

## Epyon

```

raptor root # /etc/init.d/ntpd restart

 * Stopping ntpd...                                                       [ ok ] 

* Starting ntpd...                                                       [ ok ]

raptor root # /etc/init.d/ntpd stop

 * Stopping ntpd...                                                       [ ok ]

raptor root # /etc/init.d/ntpd start

 * Starting ntpd...                                                       [ ok ]

```

works fine for me

----------

## bch

Anyone know why the lock file might not be removed??

----------

## nbensa

show us:

```
$ cat /etc/conf.d/ntp*
```

----------

## bch

Here is /etc/conf.d/ntp with all comments stripped

```

NTPD_OPTS="-U ntp"

```

Here is /etc/ntp.conf with all comments stripped

```

logfile      /var/log/ntpd.log

driftfile   /var/lib/ntp/ntp.drift

server clock.fmt.he.net      prefer

server clock.sjc.he.net

server ntp1.linuxmedialabs.com

restrict default notrust nomodify

restrict 127.0.0.1

restrict 192.168.0.22

restrict 192.168.0.0 mask 255.255.255.0 nomodify 

```

brentLast edited by bch on Sun Mar 14, 2004 6:33 pm; edited 1 time in total

----------

## nbensa

 *bch wrote:*   

> Here is /etc/conf.d/ntp with all comments stripped
> 
> ```
> 
> NTPCLIENT_CMD="ntpdate"
> ...

 

What happen if you comment out NTPCLIENT_CMD?

BTW, are you using 4.2? IME, ntp 4.2 didn't work. I've reverted back to 4.1.1b and it fixed all my problems.

----------

## bch

Im running the following version:

```

silent-srvr root # ntpd --version

ntpd: ntpd 4.1.2@1.892 Fri Mar 12 23:05:15 PST 2004 (1)

```

Opps... The NTPCLIENT_CMD="ntpdate" came from /etc/conf.d/ntp-client.

I edited previous post to make correct.

----------

## nbensa

Do you have a stale ntp process running? Try "killall ntpd" as root.

----------

## bch

```
silent-srvr root # ps aux | grep ntp

root      3044  0.0  0.4  2116 2108 ?        SL   Mar12   0:02 ntpd -p localhost

root      3330  0.0  0.4  2244 2208 ?        S    Mar12   0:00 ntpd -p localhost

root     14478  0.0  0.4  2160 2152 ?        SL   Mar12   0:02 ntpd -pe

root     12966  0.0  0.4  2288 2252 ?        S    Mar12   0:00 ntpd -pe

ntp      21255  0.0  0.4  2312 2304 ?        SL   Mar13   0:01 /usr/bin/ntpd -p /var/run/ntpd.pid -U ntp

root     24634  0.0  0.0  1524  436 pts/1    R    11:15   0:00 grep ntp

silent-srvr root # /etc/init.d/ntpd stop

 * Stopping ntpd...                                                       [ ok ]

silent-srvr root # ps aux | grep ntp

root      3044  0.0  0.4  2116 2108 ?        SL   Mar12   0:02 ntpd -p localhost

root      3330  0.0  0.4  2244 2208 ?        S    Mar12   0:00 ntpd -p localhost

root     14478  0.0  0.4  2160 2152 ?        SL   Mar12   0:02 ntpd -pe

root     12966  0.0  0.4  2288 2252 ?        S    Mar12   0:00 ntpd -pe

root      8136  0.0  0.0  1516  440 pts/1    R    11:16   0:00 grep ntp

silent-srvr root # killall ntpd

silent-srvr root # ps aux | grep ntp

root     13398  0.0  0.0  1528  440 pts/1    R    11:16   0:00 grep ntp

silent-srvr root #

```

It appears that the /etc/init.d/ntpd script is not shutting ntpd down.. The question now would be why?

```

silent-srvr root # cat /etc/init.d/ntpd

#!/sbin/runscript

# Copyright 1999-2003 Gentoo Technologies, Inc.

# Distributed under the terms of the GNU General Public License v2

# $Header: /home/cvsroot/gentoo-x86/net-misc/ntp/files/ntpd-4.1.2.rc,v 1.1 2004/02/14 22:58:02 vapier Exp $

depend() {

        need net

        use dns logger

        after ntp-client

}

checkconfig() {

        if [ ! -f /etc/ntp.conf ] ; then

                eerror "Please create /etc/ntp.conf"

                eerror "Sample conf: /usr/share/ntp/ntp.conf"

                return 1

        fi

        return 0

}

start() {

        checkconfig || return $?

        ebegin "Starting ntpd"

        touch /var/run/ntpd.pid

        chown ntp:ntp /var/run/ntpd.pid

        start-stop-daemon --start --quiet --pidfile /var/run/ntpd.pid \

                --startas /usr/bin/ntpd -- -p /var/run/ntpd.pid ${NTPD_OPTS}

        eend $? "Failed to start ntpd"

}

stop() {

        ebegin "Stopping ntpd"

        start-stop-daemon --stop --quiet --pidfile /var/run/ntpd.pid

        eend $? "Failed to stop ntpd"

}

```

----------

## nbensa

 *bch wrote:*   

> 
> 
> ```
> silent-srvr root # ps aux | grep ntp
> 
> ...

 

I think the question is "why is your box running 4 instances of ntpd?"

All my boxes show only ONE process. Can you please run:

```
# /usb/sbin/ntpd -d -n -p /var/run/ntpd.pid -U ntp
```

and watch its output? BTW, what does /var/log/ntpd.log says?

----------

## bch

I believe I had four running probably because I didnt realize that when I was running "/etc/init.d/ntpd stop" it wasnt really stopping ntpd. So then I would "rm /var/run/ntpd.pid" and then "/etc/init.d/ntpd start" and would end up with multiple instances.... Sound about right correct?

Now when I do:

```
silent-srvr root # ps aux | grep ntpd

ntp      26933  0.0  0.4  2312 2304 ?        SL   12:32   0:00 /usr/bin/ntpd -p /var/run/ntpd.pid -U ntp

silent-srvr root #

```

----------

## nbensa

Sounds correct. So it stops now?

----------

## bch

It appears to be stopping ok... But it still leaves the ntpd.pid file and then I cannot restart unless I first remove the pid file.

```
silent-srvr bin # /etc/init.d/ntpd stop

 * Stopping ntpd...                                                                              [ ok ]

silent-srvr bin # ps aux | grep ntp

root     14359  0.0  0.0  1512  440 pts/0    S    13:25   0:00 grep ntp

silent-srvr bin # /etc/init.d/ntpd start

 * Starting ntpd...

 * Failed to start ntpd                                                                          [ !! ]

silent-srvr bin # rm /var/run/ntpd.pid

silent-srvr bin # /etc/init.d/ntpd start

 * Starting ntpd...                                                                              [ ok ]

silent-srvr bin # ps aux | grep ntp

ntp      12603  0.0  0.4  2312 2304 ?        SL   13:26   0:00 /usr/bin/ntpd -p /var/run/ntpd.pid -U ntp

root      3149  0.0  0.0  1552  440 pts/0    S    13:26   0:00 grep ntp

silent-srvr bin #

```

----------

## kikibobo

For what it's worth, I'm having exactly the same problem.   :Sad: 

----------

## UberLord

The latest version in portage (~x86) works fine for me

----------

## alb

Hi all

I just emerged ntp and I got exactly the same problem for restarting

Does this mean that next time I reboot ntp will not start?

----------

