# NTP

## Binabik

I emerged ntp, I am able to "/etc/init.d/ntp-client start", it says started, when I try "/etc/init.d/ntpd start", it says

*Starting ntpd...

*Failed to start ntpd

here is my "ntp-client"

#!/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/ntp-client-4.1.2.rc,v 1.1 2004/02/16 01:56:32 vapier Exp $

depend() {

	before cron

	need net

	use dns logger

}

checkconfig() {

	if [ ! -x "`which ${NTPCLIENT_CMD} 2>/dev/null`" ] ; then

		eerror "Please edit /etc/conf.d/ntp-client"

		eerror "Unable to locate the client command ${NTPCLIENT_CMD}!"

		return 1

	fi

	if [ -z "${NTPCLIENT_OPTS}" ] ; then

		eerror "Please edit /etc/conf.d/ntp-client"

		eerror "I need to know what server/options to use!"

		return 1

	fi

	return 0

}

start() {

	checkconfig || return $?

	ebegin "Setting clock via the ntp client '${NTPCLIENT_CMD}'"

	${NTPCLIENT_CMD} >/dev/null ${NTPCLIENT_OPTS}

	eend $? "Failed to set clock"

}

Here is my ntp.conf

restrict default noquery notrust nomodify

restrict 127.0.0.1

restrict 192.168.1.0 mask 255.255.255.0

fudge 127.127.1.0 stratum 3

server ntp.cpsc.ucalgary.ca

server ntp1.cmc.ec.gc.ca

server tick.utoronto.ca

driftfile /var/lib/ntp/ntp.drift

logfile /var/log/ntp.log

Here is my 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"

}

My clock is not resetting itself

Any suggestions as to what I am leaving out

----------

## floffe

Does the log has any info in it (cat /var/log/ntp.log)? Does the pid-file (/var/run/ntp.pid) already exists? If so, delete it and try again.

EDIT: And you can try changing the "--quiet" to "--verbose" in the runscript. See if you get any more info then.

----------

## Binabik

Thanks for the reply Floffe

I did (cat /var/log/ntp.log), it had entries from Mar 26, that day I stopped it because I couldn't get the client up & running.  Then I was able to get the client running but not the ntp

I deleted (/var/run/ntp.pid) originaly it had "1329" now it has no entry in it

There is nothing new in the (cat /var/log/ntp.log) after trying to start ntp

Now I get this:

/etc/init.d/ntpd start

*Starting ntpd...

Starting /usr/bin/ntpd

Usage: /usr/bin/ntpd [a number of short cuts]

*Failed to start ntpd

The file /usr/bin/ntpd has todays date & is 263600 in size copied from mc

----------

## bmichaelsen

how about checking

```
/etc/conf.d/ntp-client
```

----------

## Binabik

# Copyright 1999-2002 Gentoo Technologies, Inc.

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

# $Header: /home/cvsroot/gentoo-x86/net-misc/ntp/files/ntp-client.confd,v 1.2 2003/09/19 17:50:37 vapier Exp $

# Command to run to set the clock initially

# Most people should just leave this line alone ...

# however, if you know what you're doing, and you

# want to use ntpd to set the clock, change this to 'ntpd'

NTPCLIENT_CMD="ntpd"

# Options to pass to the above command

# Most people should just uncomment this variable and

# change 'someserver' to a valid hostname which you

# can aquire from the URL's below

NTPCLIENT_OPTS="ntp.cpsc.ucalgary.ca"

##

# A list of available servers is available here:

# http://www.eecis.udel.edu/~mills/ntp/clock2a.html

# http://www.eecis.udel.edu/~mills/ntp/servers.html

# Please follow the rules of engagement and use a

# Stratum 2 server (unless you qualify for Stratum 1)

##

This is a copy of my /etc/conf.d/ntp-client

----------

## pjp

Moved from Installing Gentoo.

----------

## merkaba

i see some differences in your /etc/init.d/ntpd

the first 3 lines and the depend & checkconfig sections are the same, but there are some differences in the header and start/stop functions:

```

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

 

start() {

        checkconfig || return $?

 

        ebegin "Starting ntpd"

        touch /var/run/ntpd.pid

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

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

        eend $? "Failed to start ntpd"

}

 

stop() {

        ebegin "Stopping ntpd"

        if [ -e /var/run/ntpd.pid ] ; then

                kill `cat /var/run/ntpd.pid`

                rm -f /var/run/ntpd.pid

        fi

        eend $? "Failed to stop ntpd"

}

```

this is from ntp-4.2.0-r1.

you might want to try an etc-update or remerging ntp.

i see now it looks like yours is as it should be for version 4.1.2 though.

the only other thing you haven't shown is the contents of /etc/conf.d/ntpd

aside from removing any old pid files for ntpd, you might also check that there's not also a stale symlink in /var/lib/init.d/started/

----------

## Binabik

Here is a copy of my /etc/conf.d/ntpd

# Copyright 1999-2002 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.confd,v 1.1 2004/02/15 00:35:56 vapier Exp $

# Options to pass to the ntpd process

# Most people should leave this line alone ...

# however, if you know what you're doing, feel free to tweak

NTPD_OPTS="ntpd"

I didn't find any symlinks in /var/lib/init.d/started

----------

## bmichaelsen

```
NTPCLIENT_OPTS="ntp.cpsc.ucalgary.ca" 
```

should be

```
NTPCLIENT_OPTS="-b ntp.cpsc.ucalgary.ca" 
```

----------

## Binabik

I did as you suggested, but I am still receiving the same message

*Failed to start ntpd

Any other suggestions?

----------

## merkaba

try changing NTPD_OPTS in /etc/conf.d/ntpd to 

NTPD_OPTS="-U ntp" 

this is the default shown in "/usr/portage/net-misc/ntp/files/ntpd-4.1.2.confd"

----------

## Binabik

Bingo, that change started /etc/init.d/ntp start

Now the client will not start

/etc/init.d/ntp-client start

*Setting clock via the ntp client 'ntpd'...

Usage: ntpd [short cuts]

*Failed to set clock

We are getting so close

For some reason I was able to start the client before, but not the /etc/init.d/ntp, now the client will not start

----------

## merkaba

if you added the -b option to NTPCLIENT_OPTS then you might also try changing NTPCLIENT_CMD to ntpdate instead of ntpd.

----------

## Binabik

That brought us closer:

/etc/init.d/ntp-client start

*Setting clock via the ntp client 'ntpdate'...

2 Apr 23:02:36 ntpdate[2700]: the NTP socket is in use, exiting

*Failed to set clock

Were getting sooo close

----------

## jklmnop

stop ntpd, start ntp-client, start ntpd.

ntp-client needs to use the same port as ntpd for it's query.

----------

## Evil Dark Archon

change 

```
depend() {

before cron

need net

use dns logger

}

```

 to 

```
depend() {

before cron

need net

use dns logger

before ntpd

}

```

and rc-update add them both to the default runlevel

----------

## Binabik

I want to thank you all who sent me the suggestions, took me a while to get back, I am now set, time is correct, I rebooted & time was perfect

Again thanks

----------

## pumbaa

Hy there!

I had exactly the same problem ... also the history of ntpd not working while ntp-client working, then both not working, but now everythings fine ... thanks to all your posts I could fix it very fast!

Also see this post when having problems to restart ntpd ... (there's something about the ntpd.pid file not getting removed when stopping ntpd).

greets

pumbaa

----------

