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: the NTP socket is in use, exiting
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
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.
First stop the current NTP daemon running:
sudo service ntp stop
Start the NTP daemon again:
sudo service ntp start
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. 188.8.131.52 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 184.108.40.206 2 u 55 64 7 4.038 -0.613 0.110
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.
If the ntp deamen is installed and running, you would get the same error as you can't adjust the clock via two program at the same time.
If the service is running, it will sync to the servers that are in /etc/ntp.conf so time will be sync. It is better to restart ntp daemon every night so that if it stop somehow gets start everyday, set it in crontab.
crontab -e @daily sudo service ntp restart >> /tmp/time.log
you can check the details of your server sync via below command