简体   繁体   中英

How can I work out system time offset between two different linux servers?

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? Ie Is there a utility/script/command that I can use to tell me what exactly the offset is?

You can use ntpdate in query-only mode on both servers and compare the results (eg, 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.

您可以使用NTP同步2台服务器,例如ntpdate

Using a utility called clockdiff , part of the iputils package. You need to run it with root, eg sudo clockdiff <hostname> and its output looks like this:

..
host=<hostname> rtt=562(280)ms/0ms delta=-3ms/-3ms Tue Dec 12 13:34:26 2017

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM