HPUX clock drift and tricks for Oracle

Problem: HPUX clock drifts. You cant just change it to the right time, for fear of breaking Oracle. Databases don’t like when the time jumps forward, and jumping back with the clock running is a definite no.

Some Oracle sites suggest that to fix the time, you need to stop the DB, fix the time, and start it back up again. Hardly a viable solution on a prod box, unless you love working on Sunday. With HPUX, there is an easier way.

First, validate that NTP is not enabled. If it is, you have bigger problems that need fixed first. The following command should only produce one line of output:

ps -ef | grep xntpd

Ok…. so NTP isnt running. The date command on HPUX can fix the time by intentionally drifting the clock by any number of seconds. For example, to drift the clock forward two minute:

date -a 120

Or to move it back two minutes:

date -a -120

The system clock will speed up or slow down until the desired change has occurred. This has the advantage of not negatively impacting Oracle or other databases.

A handy little one-liner to help you adjust things by eyeballing the current time:

while [ true ]; do date; sleep 1; clear; done

Now that you have the time fixed, consider setting up NTP so you don’t have to do it again.