Operating System - HP-UX
1834622 Members
2871 Online
110069 Solutions
New Discussion

run ntp client 30 seconds ahead

 
SOLVED
Go to solution
Vanja
Frequent Advisor

run ntp client 30 seconds ahead

Hi,

I'm trying to see if its possible to sync up time on an ntp client +30 seconds. For example I want the ntp client to always be synced up to the ntp server +30 seconds. So say the time is 24:00:00 on the server, then client shows 24:00:30.

I need this time gap as a safety because we have issues that if certain transaction comes into the server with a time that is ahead of the current time on the system, then this causes problems with the application.

Is this possible to sync up time +30 seconds?

Thanks,
Vanja
4 REPLIES 4
Steven E. Protter
Exalted Contributor
Solution

Re: run ntp client 30 seconds ahead

Shalom Vanja,

Yes it is. Set up a local system as a time server, set it ahead of actual time by 30 seconds and make sure it uses itself as a time server.

Then any system using ntp to this altered system as a time source will run 30 seconds ahead.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor

Re: run ntp client 30 seconds ahead

Hi Vanja:

No, this is not possible. The whole idea of NTP is that a client's time is synchronized to that of its server. The very act of establishing a NTP client/server relationship means that the client time will be stepped or slewed to equal (within milliseconds) the time of the server.

Regards!

...JRF...

Bill Hassell
Honored Contributor

Re: run ntp client 30 seconds ahead

You have a very serious application design error. The application must be rewritten to properly handle the exception conditions. Changing the time is a recipe for a lot of future problems. Although you can run the system synced to itself, it will drift a lot and eventually will cause a lot of problems.

Now with all that said, yes, you can run a synchronized time offset by any value including 30 seconds. That's because HP-UX keeps time as GMT (or UTC) and TZ translates the time with offsets in hours, mins and secs.

So assuming you really want this very bad design, you can just change your local TZ to be offset by 30 seconds. The man page for environ explains all of this. Assuming your timezone is Eastern US, the normal setting for TZ would be EST5EDT, so to show the time as -30 offset, the new TZ value would be EST5:0:-30EDT. You can test it like this:

TZ=EST5EDT date
TZ=EST5:0:-30EDT date
TZ=EST5:0:30EDT date

This will show the time adjusted forward and backward. This works with any timezone. Note that if you use the date -u option, you'll see the correct GMT time which you need for stable NTP operation. The TZ value affects every application -- just change /etc/TIMEZONE after shutting down all your applications or rebooting. You don't want some programs using one time and others using a different time. TZ is set when each program is started.


Bill Hassell, sysadmin
Vanja
Frequent Advisor

Re: run ntp client 30 seconds ahead

thanks for the info!
vanja