# problem with ntp-client rc-script

## square_

```
# ntpdate -s -b -u at.pool.ntp.org
```

(successful)

```
# /etc/init.d/ntp-client start

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

 * Failed to set clock

 * ERROR: ntp-client failed to start
```

does anybody have an idea why i can start ntpdate and it set the time correctly, but the ntp-rc-script fails?

/etc/conf.d/ntp-client contains exactly the same options i use in the ntpdate code example.

----------

## yabbadabbadont

 *square_ wrote:*   

> /etc/conf.d/ntp-client contains exactly the same options i use in the ntpdate code example.

 

Post it anyway.   :Very Happy: 

Also, post your /etc/init.d/ntp-client rc script.  Perhaps it didn't (or did) get updated and that broke it.

----------

## square_

as you wish.

```
#!/sbin/runscript

# Copyright 1999-2007 Gentoo Foundation

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

# $Header: /var/cvsroot/gentoo-x86/net-misc/ntp/files/ntp-client.rc,v 1.11 2007/03/09 17:24:28 vapier Exp $

depend() {

        before cron portmap

        need net

        use dns logger

}

checkconfig() {

        if ! type "${NTPCLIENT_CMD}" >/dev/null 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}" ${NTPCLIENT_OPTS}

        eend $? "Failed to set clock"

}
```

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

# 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="ntpdate"

# Options to pass to the above command

# This default setting should work fine but you should

# change the default 'pool.ntp.org' to something closer

# to your machine.  See http://www.pool.ntp.org/ or

# try running `netselect -s 3 pool.ntp.org`.

NTPCLIENT_OPTS="-s -b -u at.pool.ntp.org"
```

----------

## square_

i dont get runscript, is ${NTPCLIENT_CMD} an environment variable? when and where does it get exported?

```
echo ${NTPCLIENT_CMD}
```

 in xterm returns an empty line. good? bad?

edit: im using openrc, btw. dont know if that is stable yet, or if it makes any difference.

----------

## yabbadabbadont

Your config looks fine to me and your init.d script is the same as mine.

The environment variable is sourced from /etc/conf.d/ntp-client by runscript would be my guess.  I haven't looked at the runscript source code though to be sure.  I would guess that it looks in /etc/conf.d for a config file by the same name as the init.d script it is currently running.  That's how I would do it anyway.   :Smile: 

Since everything looks the same as mine, and it works if you run ntpdate manually, I would guess that it must be open-rc and baselayout-2 related.  I'm using the stable stuff.   :Wink: 

Just to be sure, run /etc/init.d/ntp-client instead of just ntpdate and see if it works.  If it does, then it is definitely a problem with your openrc configuration.  In which case you should probably post your issue to the openrc support thread.

----------

## square_

is it an environment variable though? maybe it just reads out the file of the same name in /etc/conf.d/ at execution time?

 *yabbadabbadont wrote:*   

> Just to be sure, run /etc/init.d/ntp-client instead of just ntpdate and see if it works.

 what do you mean?

----------

## square_

```
# export NTPCLIENT_CMD="ntpdate"

# export NTPCLIENT_OPTS="-s -b -u at.pool.ntp.org"
```

```
# echo ${NTPCLIENT_OPTS} 

-s -b -u at.pool.ntp.org

# echo ${NTPCLIENT_CMD} 

ntpdate
```

still fails.

----------

## yabbadabbadont

 *square_ wrote:*   

> is it an environment variable though? maybe it just reads out the file of the same name in /etc/conf.d/ at execution time?
> 
>  *yabbadabbadont wrote:*   Just to be sure, run /etc/init.d/ntp-client instead of just ntpdate and see if it works. what do you mean?

 

I mean, as root, type in a terminal window:

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

And hit enter....

Does it work?

----------

## square_

with or without "start" as argument? im sorry but i cant follow you  :Very Happy: 

```
/etc/init.d/ntp-client start
```

 gives the error message in the first post.

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

 returns a help message because of missing arguments.

----------

## yabbadabbadont

<insert face palm slap>Doh!  I forgot the "start" option.   :Laughing: 

I would bring your issue up on the openrc support thread and see if the dev has any suggestions for trouble-shooting this.  Because you are using openrc and baselayout2, comparing your system to mine isn't really valid at this point.

----------

## square_

k, im not convinced that its an openrc issue, but i made a post in the support thread.

----------

## tarpman

What is the return code from ntpdate when you run it manually?

```
# ntpdate -s -b -u at.pool.ntp.org

# echo $?
```

----------

## square_

 *tarpman wrote:*   

> What is the return code from ntpdate when you run it manually?
> 
> ```
> # ntpdate -s -b -u at.pool.ntp.org
> 
> ...

 1

hmm

what ports does ntp use? most are blocked here. i never looked into it because i thought ntpdate is successful. it isnt, it just doesnt tell me.

----------

## tarpman

```
ntp      123/tcp            # Network Time Protocol

ntp      123/udp
```

----------

