ntpdate fails to get a server from /etc/ntp.conf

Bug #176844 reported by François Marier
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
ntp (Ubuntu)
Invalid
Medium
Unassigned

Bug Description

Binary package hint: ntp

It looks like ntp never updates the time on my Gutsy machine. I can get

ntpdate to work only if I specify the ntp server on the command line.

Here's what I get when I run ntpdate:

  $ sudo ntpdate -v

  17 Dec 18:51:03 ntpdate[2545]: ntpdate 4.2.4p0@1.1472-o Thu Oct 4 20:58:46 UTC 2007 (1)

  17 Dec 18:51:03 ntpdate[2545]: no servers can be used, exiting

but it does work if I specify the NTP server explicitely:

  $ sudo ntpdate -v ntp

  17 Dec 18:51:37 ntpdate[2556]: ntpdate 4.2.4p0@1.1472-o Thu Oct 4 20:58:46 UTC 2007 (1)

  17 Dec 18:51:37 ntpdate[2556]: adjust time server 192.168.4.9 offset -0.021603 sec

Which is weird since /etc/default/ntpdate.conf is the following:

  NTPDATE_USE_NTP_CONF=yes

  #NTPSERVERS=""

  NTPOPTIONS=""

and /etc/ntp.conf contains:

  server ntp

  server nz.pool.ntp.org

  server ntp.ubuntu.com

Now, I ran strace on ntpdate and it looks like it doesn't even read /etc/ntp.conf:

  $ sudo strace ntpdate 2> errors

  $ grep ntp errors:

  execve("/usr/sbin/ntpdate", ["ntpdate"], [/* 44 vars */]) = 0

  write(2, "ntpdate[2649]: no servers can be"..., 47ntpdate[2649]: no servers can be used, exiting

Is there anything else I should look into?

-- System Information:

Debian Release: lenny/sid

  APT prefers gutsy-updates

  APT policy: (500, 'gutsy-updates'), (500, 'gutsy-security'), (500, 'gutsy-proposed'), (500, 'gutsy-backports'), (500, 'gutsy')

Architecture: i386 (i686)

Kernel: Linux 2.6.22-14-generic (SMP w/2 CPU cores)

Locale: LANG=en_NZ.UTF-8, LC_CTYPE=en_NZ.UTF-8 (charmap=UTF-8)

Shell: /bin/sh linked to /bin/dash

Versions of packages ntp depends on:

ii adduser 3.103ubuntu1 Add and remove users and groups

ii libc6 2.6.1-1ubuntu10 GNU C Library: Shared libraries

ii libcap1 1:1.10-14build1 support for getting/setting POSIX.

ii libreadline5 5.2-3build1 GNU readline and history libraries

ii libssl0.9.8 0.9.8e-5ubuntu3.1 SSL shared libraries

ii lsb-base 3.1-23.1ubuntu3 Linux Standard Base 3.1 init scrip

ii netbase 4.29ubuntu2 Basic TCP/IP networking system

ii perl 5.8.8-7ubuntu3.1 Larry Wall's Practical Extraction

ii sysv-rc 2.86.ds1-14.1ubuntu31 System-V-like runlevel change mech

ntp recommends no packages.

-- no debconf information

Revision history for this message
Hew (hew) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. You reported this bug a while ago and there hasn't been any activity in it recently. We were wondering is this still an issue for you? Can you try with the latest Ubuntu release, Hardy Heron? Thanks in advance.

Changed in ntp:
importance: Undecided → Medium
status: New → Incomplete
Revision history for this message
François Marier (fmarier) wrote :

Exact same problem on hardy.

Changed in ntp:
status: Incomplete → Confirmed
Revision history for this message
Ulf Adams (ulf-ofahrt) wrote :

This doesn't seem to be a valid bug:

1. The man-page for ntpdate says explicitly, that ntpdate requires a server parameter, for example:

ntpdate ntp.ubuntu.com

2. The documentation in /etc/default/ntpdate.conf says explicitly, that it is only used by ntpdate-debian.

3. If you use ntp, you shouldn't need to use ntpdate.

If you want to invoke ntpdate, you can simply call ntpdate-debian.

Revision history for this message
Hew (hew) wrote :

That looks right to me, the man page says a server must be specified. The bug report is therefore being closed for this reason. Please reopen the bug if you disagree with this assessment. Thank you again for taking the time to report this bug and helping to make Ubuntu better. Feel free to submit any future bugs you may find.

Changed in ntp:
status: Confirmed → Invalid
Revision history for this message
phamti (tinmanemail-reg) wrote :

Hi,

This may not be a bug but I think it leads to confusion for everyone. May I suggest changing the comments in /etc/default/ntpdate as follows,

# The settings in this file are used by the program ntpdate-debian, but not
# by the upstream program ntpdate.
#
# ntpdate requires a server parameter, for example:
# ntpdate ntp.ubuntu.com

Also, I notice that the script file /etc/network/if-up.d/ntpdate seems to work. It is not obvious to me how the script know what time server to use.

Revision history for this message
phamti (tinmanemail-reg) wrote :

Hi Hew,

I think this should be addressed. Also would you be able to let us know how /etc/network/if-up.d/ntpdate knows which time server to use?

Changed in ntp:
assignee: nobody → hew
Revision history for this message
Hew (hew) wrote :

phamti, you should not assign bugs to anyone other than yourself. This bug is also closed. If you believe a reported bug still exists you should reopen it, but if you are talking about a different issue then you should open a new bug report for it.

/etc/default/ntpdate is well commented, and you should pay attention to the first line. It is not used by ntpdate, but by ntpdate-debian. Adding a comment about ntpdate would not reduce confusion, but increase it ;-)

/etc/network/if-up.d/ntpdate is also commented, and clearly executes ntpdate-debian and not ntpdate. Please read the relevant man pages.

This is a bug report and not the place for support. In future you can ask questions at answers.launchpad.net , or at relevant irc channels or forums. However it's always best to first RTFM (F = Friendly) :-)

Changed in ntp:
assignee: hew → nobody
Revision history for this message
phamti (tinmanemail-reg) wrote :

Hi,

Sorry about assigning the bug. The system allowed me to so I thought that was how you do it.

I was just suggesting a quick fix. Long term I suggest since,

- ntpdate does not use ntpdate.conf rename it to ntpdate-debian.conf
- /etc/network/if-up.d/ntpdate does not use ntpdate so rename it /etc/network/if-up.d/ntpdate-debian.conf

As a note I did check the manual https://help.ubuntu.com/7.10/server/C/NTP.html and google (other people were confused too). I will go to the manual team and provide suggestions for clarification.

Hew, your response most likely was not meant in a negative way but at least when I first read it, it felt a bit negative. Maybe ask someone else outside to read it. I did, and they felt it was worth mentioning.

Revision history for this message
maccus (maccus) wrote :

I clean installed Ubuntu Karmic in october 2009 and just discovered that my system time is 15 minutes off. I had ntp as well as ntpdate installed, but it clearly never synchronized. The time and date applet in the panel doesn't work either. I deinstalled ntp and manually executed ntpdate ntp.ubuntu.com and the right time was set. So how come this is not marked as a bug? Is it a feature that Karmic won't update the time?

Revision history for this message
itsjustarumour (itsjustarumour-gmail-deactivatedaccount-deactivatedaccount) wrote :

Same problem hAdministrationere on all my Karmic (32-bit) boxes. Clocks went forward an hour last night, but system time didn't change. Wheither I go System>Administration>Time and Date, or try this via the Clock?Calender applet, teh settings have no effect.

If I run ntpdate in terminal, I get:

ian@COOLERMASTER:~$ sudo ntpdate
28 Mar 06:09:35 ntpdate[7823]: no servers can be used, exiting
ian@COOLERMASTER:~$

I've tried several time servers but its always the same..

Revision history for this message
itsjustarumour (itsjustarumour-gmail-deactivatedaccount-deactivatedaccount) wrote :

Sorry, bugtracker garbled my comment above, should read:

Same problem on all my Karmic (32-bit) boxes. Clocks went forward an hour last night, but system time didn't change. Wheither I go System>Administration>Time and Date, or try this via the Clock?Calender applet, teh settings have no effect.

If I run ntpdate in terminal, I get:

ian@COOLERMASTER:~$ sudo ntpdate
28 Mar 06:09:35 ntpdate[7823]: no servers can be used, exiting
ian@COOLERMASTER:~$

I've tried several time servers but its always the same.

For what its worth, I have both ntp and ntpdate installed.

Revision history for this message
C de-Avillez (hggdh2) wrote :

@itsjustarumour: This bug has been closed for quite a long time. It would be better to open a new bug.

Anyway: ntpdate will fail if ntp is running. This is expected, per design, and how it works.

Revision history for this message
david6 (andrew-dowden) wrote :

I may yet open a new bug, but in the meantime some comments ..

> ntpdate fails to get a server from /etc/ntp.conf

YES.

In my testing (Ubuntu 12.10, server, 64bit), ntpdate does NOT use the NTP servers listed in /etc/ntp.conf. Therefore, not honouring the setting: NTPDATE_USE_NTP_CONF=yes in file: /etc/default/ntpdate

However, NTP and NTPDATE don't play well, and really only NTP needs to work once the system is running (and 'nearly' synced). You also need to stop/start NTP, before/after attempting to use NTPDATE:

    ntpq -np
    ntpq -c rl

    sudo service ntp stop
    ntpdate -q 1.au.pool.ntp.org
    sudo service ntp start

    ntpq -np
    ntpq -c rl

And (surprise) NTPDATE uses a completely different file (/etc/ntp/step-tickers) to list time servers, to get the initial reasonable time sync, to allow NTP to then keep in sync.

Note: Ubuntu (even 12.10) does not have this file, or even the directory (/etc/ntp/), but does appear to use it (if created).

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.