views:

63

answers:

2

We have two Linux servers, ServerA and ServerB. The system time on ServerA seems to be slightly behind ServerB, only by a few hundredths of a second.

I am trying to diagnose an issue with a distributed transaction and have noticed slight inconsistencies between the times of the two servers, but I need some way to prove it. I need something that will tell me "ServerA is 0.002 of a second behind ServerB". Perhaps not as verbose as this but you get the picture.

Is there any way to prove this? I.e. Is there a utility/script/command that I can use to tell me what exactly the offset is?

A: 

you can use NTP to sync the 2 servers, eg ntpdate

ghostdog74
+1  A: 

You can use ntpdate in query-only mode on both servers and compare the results (e.g., how far out does it report each server to be). Compare them against the same time source, of course. And recommend to the admins that if the machines aren't already keeping themselves up to date with ntpd, they should be. If timing is that critical to what you're doing, you should have a local timeserver that periodically syncs to the outside world, and which your local servers sync with.

T.J. Crowder
I get the following error when trying to query ntpdate: 19 Feb 07:35:45 ntpdate[4888]: no servers can be used, exiting
rmcc
@rmcc: You need to tell it what server to use as a command-line argument (see the man page for details, "man ntpdate" or http://www.manpagez.com/man/8/ntpdate/) because it's apparently not configured to use a default. You can find lists of servers on the ntp.org page (http://psp2.ntp.org/bin/view/Servers/WebHome). Be sure to query the same server on both of your machines, just to rule out synchronization issues between the servers. Pick the server carefully, there are round-robin DNS options (pool.ntp.org, for instance) that will assign you a different server every time you look them up. HTH.
T.J. Crowder
@rmcc: You may also be running into a firewall issue. Sometimes using a lower-privilege port is useful, `ntpdate -q -u time.server.name` (`-q` is query-only, `-u` is use a userland port). Another possibility (although I'd be a bit surprised) is long lags between you and the time server. In that situation, `-t 5` might help (increase the timeout to five seconds).
T.J. Crowder