1829683 Members
7155 Online
109992 Solutions
New Discussion

NTP forced sync

 
Starrynight_1
Advisor

NTP forced sync

Hello all

Just a "simple" question.
Is there any way to force NTP deamon to syncronize the hour with the peers even if the diference between server's hour is more than 1000 seconds?

Thanks in advance.

SN
7 REPLIES 7
Juan Manuel López
Valued Contributor

Re: NTP forced sync

You can stop and start NTP Daemon ( xntpd ) or send a kill -1 signal to it.
Try this and tell us how does it works.
Juanma.
I would like to be lie on a beautiful beach spending my life doing nothing, so someboby has to make this job.
Robert-Jan Goossens
Honored Contributor

Re: NTP forced sync

Hi,

/sbin/init.d/xntp stop

ntpdate ip-adres-timeserver

/sbin/init.d/xntpstart

Regards,

RoebrtJan.
Pete Randall
Outstanding Contributor

Re: NTP forced sync

SN,

You can use ntpdate to accomplish this, but you need to be certain there will be no adverse effects. Database logs, in particular, don't like to have their time set backwards. Use with caution.

Pete

Pete
Timo Ruiter
Advisor

Re: NTP forced sync

Hello,

As far as I know NTP will allow synchronisation to a server that has a time difference of less than one hour. It will take a huge time step, but it will (should) work. If the time difference is more than one hour, no attempts are made to synchronize times; an error message is logged indicating that the difference is too great and the time should be set manually, somewhere around the actual time, after which xntpd can take over.
In other words, the xntpd process does not have to be killed or restarted in order to synchronize times. It can take a while, however, NTP is a slow process.

Hope this helps,

Timo
Confucius say: he who runs through forrest in straight line will hit tree
James R. Ferguson
Acclaimed Contributor

Re: NTP forced sync

Hi:

The subject of time keeping and the "danger" of abruptly stepping time (particularly backwards) has been discussed often.

By design, the 'xntpd' daemon will die if the difference in the server's time and the clock to which it is try to synchronize is greater than 1000 seconds. This prevents synchronizaton to a clock that has run wild.

In my opinion, if you are initially correcting such a difference is times you should shutdown all databases, manually set the time and reboot to start 'cron', 'xntpd' and your applications cleanly and quickly. Yes, you can use 'ntpdate' to step or slew the time (see its man pages), and yes, you can use 'data -a' to slew the time but these methods will take quite a while to bring synchronization. If correct timekeeping has mattered little to you then a reboot shouldn't matter either.

Regards!

...JRF...

John Payne_2
Honored Contributor

Re: NTP forced sync

If you really want to do this the quick and dirty way, leave ntp running, and set the system date to a time very close. use:
date -u mmddhhmm
Then, if you are close, like a minute or so, ntp will sync the time.

Note: The date command is used in UTC (Universal time.) For me in Utah, we are something like 7 or 8 hours behind Universal Time. I always get mixed up about which right after a Daylight Savings change...

Hope it helps

John
Spoon!!!!
A. Clay Stephenson
Acclaimed Contributor

Re: NTP forced sync

This is one of those "it depends" questions. If you are
setting the time forward then there is no real problem setting the date forward with a date command or an ntpdate command to steo the time forward abruptly. You would the start the NTP daemon and all would be well.

However, if you need to set the time backwards then the above method is very dumb. It is very possible that you would have a database transaction where transaction 1000 happens before transaction 999. Try to explain to a customer why his A/R is correct in that case!
On development machines where timestamps are used to determine source/object file dependencies, you can confuse the make utility terribly. You can also cause incremental backups to miss files. For these reasons, if you must adjust time, the smart play is to use date -a to slew the time. The time might not be accurate for a bit but it would be self-consistant.

If it ain't broke, I can fix that.