Showing results for 
Search instead for 
Did you mean: 

Sync system time

Frequent Advisor

Sync system time

We have many servers , some are local (koera) time ( GMT +9 ) , eg. server A , some are GMT time eg, server B , I want to sync all these server time regularly to make sure they are same system time .

Now Server A is sync. with koeran country authory so its time should be correct . I am thinking is it a good way to set a schedule job in server B to get the time from server A , then run a scrpt ( in server B ) to set -9 hours for example , after server B get the time from server A , the current time is 10:00am , then run a script ( in server B ) to set -9 hours , the time will be changed to 01:00am , can advise is it a good way ? Thanks.
Steven Schweda
Honored Contributor

Re: Sync system time

Why not sync Server B with the same time
standard, using the same method, as you use
for Server A? A system does not need to be
in the same time zone as its time standard

I assume that you're using something like NTP
to control the time on Server A. If you said
what you really are doing, then it might be
easier to make useful suggestions.

Re: Sync system time

>some are local (koera) time (GMT+9)

(I assume this is for Korea?)

What does "date -u; date" show for both? They both should show the same time for UTC.

As Steven mentions, you should use NTP to synchronize the UTC times and then export TZ to the correct timezones.
Honored Contributor

Re: Sync system time

All unix systems understand multiple timezones: this is a standard POSIX feature.

Setting the clock backwards (e.g. from 10:00 AM to 01:00 AM) while applications are running is not recommended: it might cause incorrect timestamps to be recorded in databases and logs.

If those timestamps are subject to further processing, it might cause wrong results: for example, in a server that creates billing information for phone calls, setting the clock backwards 9 hours might cause the system to record the duration of a 15-minute call as "minus 8 hours 45 minutes". This might cause a negative amount to be billed, which might be embarrassing to the company.

All Unix systems should have their timezone settings set correctly. This will allow the systems to make correct timezone conversions whenever required.

In fact, the standard Unix system clock always runs in GMT/UTC time: if the system is set to use a local timezone, it only means all time information entered by the user is converted to UTC for processing and internal storage, and back to local timezone for output.

If you need to synchronize the clocks of your servers using local time information and the server is using some different timezone by default, you'll only need to specify the appropriate timezone when setting the time.

For example, on exactly 10:00 AM on 2011-Jan-2, you might run this command on server B, _even if server B is set to use GMT by default_:

TZ=KST-9 date 010210002011

The "date" command will check the TZ variable (like all HP-UX programs) and will understand that the new time value is specified using Korean timezone. The command will then automatically convert the time to GMT/UTC timezone before setting the system clock.

If you use time synchronization tools "ntpdate" or "xntpd", you should be aware that the NTP time synchronization protocol will only ever transmit time information in GMT/UTC time. The synchronization tools are designed to be aware of this, and will automatically do the right thing.

If your timezone settings are correct, you'll automatically get the right results: the systems set to Korean timezone the clock will display the correct Korean time, and the systems set to GMT will display the correct GMT time.

Doug O'Leary
Honored Contributor

Re: Sync system time


ntp is the answer you're looking for. "man xntpd" on hpux and google ntpd for some freely available time sync masters.

ntp is incredibly easy to set up. Once done, all your systems will be synced to the second - and displaying their times in the local timezone (through /etc/TIMEZONE file)



Senior UNIX Admin
O'Leary Computers Inc