Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I try to synchronize time using NTP. Using the below command

sudo ntpdate -b pool.ntp.org

I get this error saying NTP socket is in use. How to fix this?

18 Jan 05:53:49 ntpdate[21340]: the NTP socket is in use, exiting
share|improve this question

the NTP socket is in use, exiting

Indicates that you have an NTP daemon running, usually the one via the ntp package. You can't have two applications adjusting the clock at the same time.

  1. First stop the current NTP daemon running:

    sudo service ntp stop
    
  2. Run your ntpdate command.

  3. Start the NTP daemon again:

    sudo service ntp start
    

Background

The NTP daemon will not take large steps forwards or backwards, but is useful for very smooth and small transitions. Before it will work correctly, sync the time using ntpdate first, for that reason. You can query the status of the daemon like this:

ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*chime1.surfnet. 194.171.167.130  2 u   59   64    7    3.159   -0.207   0.136
+chime2.surfnet. .GPS.            1 u   59   64    7    6.872   -0.592   0.091
[...]
 ns1.tudelft.nl  .INIT.          16 u    -   64    0    0.000    0.000   0.000
+ev001.tilaa.nl  193.67.79.202    2 u   55   64    7    4.038   -0.613   0.110
share|improve this answer
    
Ubuntu ships openntpd and not xnptd as a default? ntpq is from xntpd. – Martin Schröder Jan 18 '13 at 10:23
    
@MartinSchröder You're right! :) Editing now. Thanks. – gertvdijk Jan 18 '13 at 10:44
    
Correction: ntpq is from the ntp reference implementation. In the 90s and early 00s it was called xntpd, it is now just ntpd or ntpv4. – dfc Jan 19 '14 at 17:02
    
Great explanation - I never knew why ntp wouldn't make the large leaps. – Jeremy Hajek Sep 9 '14 at 2:47
    
+1 I enabled ntpd and expected to see it correct my time (which was 2 minutes out), as a proof it was working. But of course it won't do that because it "will not take large steps forwards or backwards". Thanks for the explanation – matt freake Mar 26 '15 at 11:26

If you get the Error NTP socket in use as shown below:

enter image description here

In that case just run

$ sudo service ntp stop
$ sudo ntpdate pool.ntp.org
$ sudo service ntp start

and you will get

enter image description here

OR JUST RUN

sudo ntpdate -u pool.ntp.org

to update with the ntpd deamon running

share|improve this answer
2  
Dont encourage people to run ntpdate when ntpd is running – dfc Mar 5 '14 at 14:29
1  
Why posting screenshots with just text? Copy & paste 'just works'. ;-) – gertvdijk Sep 9 '14 at 8:03
1  
+1 for the -u option which avoids the hasle of stopping ntpd – dan carter Jun 10 '15 at 1:34

A common problem is that people discover that their computer has not updated at the appointed DST (Daylight Saving Time) transition. Once recognized, the user attempts to correct the time with sudo ntpdate -b pool.ntp.org or similar only to discover that NTP is already running and simply didn't work.

In the general case, NTP simply cannot be trusted to correct your clock at DST transitions. For example, NTP has cases in which it will refuse to set your clock. You get tons of hits when searching for NTP problems, so clearly the limitations of NTP have affected many people. I'm sure there are solid reasons for any NTP design decision, but that doesn't change the fact that it can't be trusted to always do what the average user would expect.

Be sure to check up on it if is important to you for some specific purpose. You may have greater luck with an automatic DST transition if you manually set the correct time shortly prior to the transition.

This is a hard problem for the average user to experiment with, since DST only happens at two instances per year.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.