How to Compare Difference Time between two Linux

Comparing difference time between two linux operating system is needed to make sure a computer time is equal to the other computer, this affair commonly used by researcher to synchronize 2 pc that used linux operating system. One of linux package that is able to compare the difference between two PC is “NTP”.


PC spesification used for this tutorial :
Debian 7 OS
Intel i5 CPU
ASUS motherboard
lxterminal or gnome terminal

Introduction

NTP is abreviation of Network time protocol, this package is an operating system daemon that has an ability to syncrhonize the clock time between two computer.

Determining the time difference

Before we calculating the time difference between two PC, just make sure that one PC is running an NTP server daemon:

Download NTP Server

to download ntp server daemon you can use this command in linux terminal: (if one of your PC has this package installed, just ignore this step)
sudo apt-get install ntp


here the result :
root@elbirtus:/home/elbirtus# sudo apt-get install ntp
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
lockfile-progs
Use 'apt-get autoremove' to remove it.
Suggested packages:
ntp-doc
The following NEW packages will be installed:
ntp
0 upgraded, 1 newly installed, 0 to remove and 124 not upgraded.
Need to get 0 B/394 kB of archives.
After this operation, 1,289 kB of additional disk space will be used.
Selecting previously unselected package ntp.
(Reading database ... 135669 files and directories currently installed.)
Preparing to unpack .../ntp_1%3a4.2.6.p5+dfsg-7_i386.deb ...
Unpacking ntp (1:4.2.6.p5+dfsg-7) ...
Processing triggers for systemd (215-17) ...
Processing triggers for man-db (2.7.0.2-5) ...
Setting up ntp (1:4.2.6.p5+dfsg-7) ...
update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults
insserv: warning: current start runlevel(s) (empty) of script `ntp' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `ntp' overrides LSB defaults (empty).

2. now you need to run the ntp service on the time server:
sudo /etc/init.d/ntp start

here the result :

elbirtus@elbirtus:/home/elbirtus# sudo /etc/init.d/ntp start
[ ok ] Starting ntp (via systemctl): ntp.service.


3. Now in the other PC (Client PC), you need to run ntpdate command, but ntpdate commonly is not pre-installed package, so you need install it first by running this command in your terminal:

sudo apt-get install ntpdate

here the result:

sudo apt-get install ntpdate

Reading package lists... Done
Building dependency tree

Reading state information... Done
The following packages were automatically installed and are no longer required:
audacious audacious-plugins audacious-plugins-data libaudcore2
libbinio1ldbl libcddb2 libcue1 libfluidsynth1 libguess1 libmms0 libmodplug1
libsidplayfp3
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
ntpdate
0 upgraded, 1 newly installed, 0 to remove and 45 not upgraded.
Need to get 57,4 kB of archives.
After this operation, 251 kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
ntpdate
Install these packages without verification? [y/N] y
Get:1 http://id.archive.ubuntu.com/ubuntu/ vivid-updates/main ntpdate amd64 1:4.2.6.p5+dfsg-3ubuntu6.2 [57,4 kB]
Fetched 57,4 kB in 8s (6.834 B/s)

Selecting previously unselected package ntpdate.
(Reading database ... 210938 files and directories currently installed.)
Preparing to unpack .../ntpdate_1%3a4.2.6.p5+dfsg-3ubuntu6.2_amd64.deb ...
Unpacking ntpdate (1:4.2.6.p5+dfsg-3ubuntu6.2) ...
Processing triggers for man-db (2.7.0.2-5) ...
Setting up ntpdate (1:4.2.6.p5+dfsg-3ubuntu6.2) ...

4. Now from the client PC, type this command, (in this tutorial the server ip is 202.4.186.76), you can change the server ip or domain as you wish :

Ntpdate -q 202.4.186.76


Here is the result:

ntpdate -q 202.4.186.76
server 202.4.186.76, stratum 3, offset -0.086288, delay 0.16693
20 Dec 12:50:08 ntpdate[3796]: adjust time server 202.4.186.76 offset -0.086288 sec

From this result we have an information that between PC server and Client server there is a difference time, the difference time is the value of offset, in this case, the difference between both time is -0.086288 second. The minus sign means that the PC Client have a bigger time value than PC Server.

Komentar

Postingan populer dari blog ini

Which television show centered around the lives of the Carrington family?

Donald Trump will be the first to serve two non-consecutive terms since which commander in chief?