How to force host clock sync or update using public NTP ?
This tutorial guides you on how to force host clock sync or update with public NTP using ntpdate command or by setting up NTP and configuring host to sync with public NTP.
Force host clock sync or update using public NTP
I was using Ubuntu development VM and which uses ubuntu.pool.ntp.org as NTP Time server and it is not in sync with the browser (local windows machine) as it was using time.windows.com as NTP server.
And I need to keep these two (Ubuntu machine and local Windows machine) host clock sync or to make it to use same public NTP with date and time synchronized. Therefore, I can do some performance testing to measure elapsed time for the data packets to travel end-to-end.
Note, I was not able to change the NTP Time Server to point to different from time.windows.com as it is office laptop and I don’t have permissions to do so. Hence, I decided to force the ubuntu host clock sync to the same NTP Time server as that of Windows which is time.windows.com.
Force a clock sync or update using ntpdate
sudo apt-get install ntpdate
If you had installed NTP service and if it is up and running, make sure that you stop before you force update clock settings using ntpdate command. Otherwise you may get the error “can’t open the socket (port 123 UDP) and connect to ntp server.”
sudo service ntp stop
Then run the following command to change the host’s clock settings.
sudo ntpdate time.windows.com
Finally, start the ntp service.
sudo service ntp start
That’s it. You’r host clock is synced to public NTP time.windows.com.
Setup NTP and configure host to sync with public NTP
If you had not installed NTP or alternatively you can setup NTP and configure host to synchronize with a public NTP Server.
sudo apt-get install ntp
2: Check status of ntp Stop ntp service
sudo service ntp status
Stop the service
sudo service ntp stop
3: Edit ntp.conf file to update the required public NTP server settings i.e., the public NTP server that you would like to synchronize your host clock.
sudo nano /etc/ntp.conf
Comment out the NTP servers (configurations starts with pool*) listed. And add the following NTP server configuration: pool time.windows.com as shown below.
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help driftfile /var/lib/ntp/ntp.drift # Leap seconds definition provided by tzdata leapfile /usr/share/zoneinfo/leap-seconds.list # Enable this if you want statistics to be logged. #statsdir /var/log/ntpstats/ statistics loopstats peerstats clockstats filegen loopstats file loopstats type day enable filegen peerstats file peerstats type day enable filegen clockstats file clockstats type day enable # Specify one or more NTP servers. # Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board # on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for # more information. #pool 0.ubuntu.pool.ntp.org iburst #pool 1.ubuntu.pool.ntp.org iburst #pool 2.ubuntu.pool.ntp.org iburst #pool 3.ubuntu.pool.ntp.org iburst # Use Ubuntu's ntp server as a fallback. #pool ntp.ubuntu.com pool time.windows.com ----- -----
4: Finally, check if host clock is updated with public NTP time server
$ ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== time.windows.co .POOL. 16 p - 64 0 0.000 0.000 0.001 +10.38.72.8 (css 10.38.72.7 2 u 481 1024 377 295.347 3.033 0.542 *10.24.64.8 (css 10.38.64.7 2 u 820 1024 377 200.277 0.553 1.168 +10.38.64.8 (ntp 10.38.64.7 2 u 255 1024 377 289.660 -0.653 0.762
That’s it, you had forced host clock to sync with the public NTP Time server.
Hope this article is helpful 🙂
Also See:
- Set or change root password in Ubuntu Linux
- Linux: sudo: apt-get: command not found
- Install GUI on Ubuntu Server ?
- How to Start Stop Restart MariaDB on Linux OS ?
- Putty Fatal Error No supported authentication methods available
- How to find which users belongs to a specific group in linux
- Give write permissions for specific user or group for specific folder in linux
- How to unzip a zip file from Terminal (Google Cloud Shell)
- Build a Docker Image with a Dockerfile and Cloud Build in GCP?
- Generate merged code coverage report for JUnit and BDD tests in Sonar using Jacoco
- MariaDB – How to set max_connections permanently ?
- How to create GCP project on Google Cloud Platform
- Is it possible to change Google Cloud Platform Project ID ?
- Create non-root SSH user account and provide access to specific folders
- MySQL : How to grant all privileges to the user on database ?
- How to install OpenJDK 11 in Ubuntu Machine ?
- Amazon Linux AMI : apt-get command not found
- How to get the first and last element of a list in Python ?
- Connect to Github using SSH ?
- Check OS version in Linux from command line ?
- Error: You’ll have to kill the Xvnc process manually
- How to install and configure VNC on Ubuntu 20.04 with graphical desktop?