Thursday, December 8, 2016

Time Synchronisation with NTP

Last week working on one of project, I found that my server UTC time is running 2 min 30 seconds behind actual UTC time.

I asked one of my senior and he told me to run following command :

 sudo ntpdate pool.ntp.org  

This gave me the desired result and my server time is synched with actual UTC time.

After that I googled the command and found more facts about this.

What is NTP

NTP (Network Time Protocol)  is a TCP/IP protocol for synchronising time over a network. Basically a client requests the current time from a server, and uses it to set its own clock.

For fixing the time I run the "ntpdate" command but "ntpdate" is not an action that should be taken regularly because it syncs the virtual server’s time so quickly, the jump in time may cause issues with time sensitive software. Therefore, it is best to run this only once, prior to setting up NTP, and then let NTP take over—otherwise, if the server’s time is too far off, NTP may not launch altogether.

Installing the NTP

To download or install NTP, run the following command on Ubuntu

 sudo apt-get install ntp  

Configuring the NTP Servers

After installing, open the following configuration file

 sudo nano /etc/ntp.conf  

It will show the lists of NTP Pool Project servers like below

 server 0.ubuntu.pool.ntp.org;  
 server 1.ubuntu.pool.ntp.org;  
 server 2.ubuntu.pool.ntp.org;  
 server 3.ubuntu.pool.ntp.org;  

Each line then refers to a set of hourly-changing random servers that provide our server with the correct time. The servers that are set up are located all around the world, and we can see the details of the volunteer servers that provide the time with the following command

 ntpq -p  

This command will output like below

  remote      refid   st t when poll reach  delay  offset jitter  
 ================================================================  
 -mail.fspproduct 209.51.161.238  2 u  50 128 377  1.852  2.768  0.672  
 *higgins.chrtf.o 18.26.4.105   2 u 113 128 377  14.579  -0.408  2.817  
 +mdnworldwide.co 108.71.253.18  2 u  33 128 377  47.309  -0.572  1.033  
 -xen1.rack911.co 209.51.161.238  2 u  44 128 377  87.449  -5.716  0.605  
 +europium.canoni 193.79.237.14  2 u 127 128 377  75.755  -2.797  0.718  

Although these servers will accomplish the task of setting and maintaining server time, we can set our time much more effectively by limiting the ntp to the ones in our region (europe, north-america, oceania or asia), or even to the ones in our country, for example in America:

 us.pool.ntp.org  

We can find the list international country codes (although not all of the countries have codes) here

Once all of the information is in the configuration file, restart ntp with following command:

 sudo service ntp restart  

NTP will slowly start to adjust the virtual private server’s time.

Thanks

3 comments:

  1. Have you mistakenly withdrawn your funds to the wrong address through Binance? Now willing to have an appropriate platform so to become free from such troubles? If yes, then Binance Support Number instantly call our Binance support number that you may dial without taking any stipulated time into consideration. Our expert team works 24/7 hours incessantly to provide you the solution in no time. Thus users may feel free to contact us without thinking anything to talk to the related executives.

    ReplyDelete
  2. Have you mistakenly withdrawn your funds to the wrong address through Binance? Now willing to have an appropriate platform so to become free from such troubles? If yes, then instantly call our Binance support number 1-833-993-0690 that you may dial without taking any stipulated time into consideration. Our expert team works 24/7 hours incessantly to provide you the solution in no time. Thus users may feel free to contact us without thinking anything to talk to the related executives.
    Binance Support Number
    Binance Customer Support
    Binance Phone Number
    Binance Customer Service

    ReplyDelete
  3. QuickBooks is very useful software which resolve your all query related to QuickBooks issue just visit at QuickBooks Customer Service

    ReplyDelete