Operating System - HP-UX
1834114 Members
2268 Online
110063 Solutions
New Discussion

About setting system time.

 
Kenny Chau
Trusted Contributor

About setting system time.

To all,

I want to set the system time backwards for about 15 mins. Do you know any harmful effects to my server without shutting down the server? Or is it necessary to reboot the server after reset the time?

ps. I had tried to use NTP to synchronize the time with other server but failed with following message:

time error -1057.008354 is way too large (set clock manually)

Do you know any other methods to reset the time?

Thanks very much.

Kenny
12 REPLIES 12
James R. Ferguson
Acclaimed Contributor

Re: About setting system time.

Hi Kenny:

If you can't reboot to do this, you can use the 'date' command to slowly set time backwards:

# date -a -sss.fff

...where s=seconds and f=fractional seconds.

If you choose to do this you should plan to stop and restart the cron daemon too:

# /sbin/init.d/cron stop|start

Regards!

...JRF...
Michael Tully
Honored Contributor

Re: About setting system time.

Hi,

I would be *extremely* careful in setting
the time in reverse. Most, if not all
databases will not like at all.

Suggest you look shutting down all
applications on your system to do this
task. You don't need to reboot your system.
Once done you can restart your applications
and databases.

To actually change the date and time is
as follows:

# date 120502422001
format as [mmddhhmmyyyy]

HTH
-Michael
Anyone for a Mutiny ?
James R. Ferguson
Acclaimed Contributor

Re: About setting system time.

Hi (again) Kenny:

BTW, 'ntpd' will not synchronize your server's clock to its refererence source if the difference in time exceeds 1000 seconds or if a suitable source cannot be found in about 320 seconds.

Regards!

...JRF...
Uday_S_Ankolekar
Honored Contributor

Re: About setting system time.

Steven Sim Kok Leong
Honored Contributor

Re: About setting system time.

Hi,

On a test server that I had tried reversing the system timestamp, I observed that:

1) oracle database will act erratically eg. CPU load shoots up extremely high

2) crond will hang

It is still safer to schedule a reboot because there may be quite a few time-dependent components, unless you can keep track and shut these down before time reversion.

If your NTP server is a secured server, it is a good choice for time synchronization. However, I wonder what the impact will be if the NTP server is compromised and time is set backwards.

Hope this helps. Regards.

Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
Tom Geudens
Honored Contributor

Re: About setting system time.

Hi,
We had to do this for Euro-testing (and for Y2K, but that was before my time :-) and ran
into the following issues :
- If you do it, do it at level 1. As mentioned
in a previous reply, Oracle will crash.
- Measureware will not crash ... but extract
(of data in the specific interval) will.
- Eliminate timesynchronisation in
/etc/rc.config.d/netdaemons
- If you work in a cluster environment, make
SURE the cluster did not "pass" the time.
Example :
time 08h00
time 08h15 and you set time back to 08h00
If the cluster has run after 08h00 ...
you're in trouble (regardless of whether
you change the time at level 1 or not).

Hope this helps,
Tom Geudens
A life ? Cool ! Where can I download one of those from ?
Wim Rombauts
Honored Contributor

Re: About setting system time.

I would definitely choose for the solution provided by JRF : use date -a to slowly adjust your clock.
Do this as precise as possible, and when your system clock matches the clock of the NTP server, restart NTP and let NTP handle the rest and keep the system clocks synchronised.
Kenny Chau
Trusted Contributor

Re: About setting system time.

I had tried to use date -a -100 to slow down the clock but seems nothing happened.

Any clue??
Thanks.
Kenny
Wim Rombauts
Honored Contributor

Re: About setting system time.

I have no direct answer to that. Have you given the system time enough to adjust it's time ? It could take a while forthe system to slowly adjust the clock 100 seconds.

You are sure that xntpd is no longer running on your system ?

I just tried date -a -100 myself, and I can see the system time drifting appart slowly.
Kenny Chau
Trusted Contributor

Re: About setting system time.

Yes, I am sure that xntpd is not running and I realised that the clock is running slower than usual but really hard to realise that.
So do I need to keep type the command date -a to slow down the clock or I just need to run it once to slow down until the clock is almost same as the NTP server clock?

Thanks.
Kenny
Wim Rombauts
Honored Contributor

Re: About setting system time.

If yoour first command worked well, You can use date -a in one big step (date -a -957) to get the system clock almost synchronized with the NTP server. From that point on, you have two choises :
1) Do nothing, and the system clocks will slowly drift appart again. This drift can be very small, a few (tens of) seconds per month. Once every so many weeks, you will have to use dat -a xxx again.
2) Run NTP on your server, this software will make sure the clocks will get and stay synchronized.
Steven Gillard_2
Honored Contributor

Re: About setting system time.

Here's a program I wrote some years back. It uses the adjtime() system call which does not ever turn the clock back, it simply slows it down until the time is where you want it. This is the same system call that ntp uses to slew the clock.

This program compiles without the ANSI C compiler, just run:

$ cc -o adjtime adjtime.c

Make sure xntpd is not running at the same time otherwise it will not work. Then, to set the clock back 15min, run:

$ ./adjtime -set -900

The delta is in seconds. You can watch its progress with:

$ ./adjtime -display

And stop it with:

$ ./adjtime -zero

Regards,
Steve