adjtime -- correct the time to allow synchronization of the system clock


cc . . . -lc
#include <sys/time.h>
#include <sys/clock.h>

int adjtime(struct timeval *delta, struct timeval *olddelta);


adjtime adjusts the system's notion of the current time, as returned by gettimeofday(S), advancing or retarding it by the amount of time specified in the timeval structure pointed to by delta. This call is used by NTP (Network Time Protocol) to synchronize the system clocks of the systems in a local area network.

Parameters described on the clock(HW) manual page control the adjtime( ) functionality.

The adjustment is effected by speeding up (if the adjustment is positive) or slowing down (if the adjustment is negative) the system's clock by some small percentage, generally a fraction of one percent. Thus, the time is always a monotonically increasing function. If the requested adjustment can be performed in less than one second (determined by the maximum rate specified by the clock_drift variable described on the clock(HW) manual page), then the adjustment is performed ``smoothly'' over the course of one second. If the adjustment cannot be performed in less than one second, it is performed at the clock_drift rate.

A time correction from an earlier call to adjtime may not be finished when adjtime is called again. If delta is NULL, then olddelta returns information on the previous adjtime call and there is no effect on the time correction as a result of this call. If olddelta is not NULL, then the structure it points to contains, on return, the time still to be corrected from the earlier call. If olddelta is NULL, the information is not returned.

Only a process with an effective user ID of 0 can adjust the system clock.

Return values

On success, adjtime returns 0. On failure, adjtime returns -1 and sets errno to identify the error.


In the following conditions, adjtime fails and sets errno to:

delta or olddelta points outside the process's allocated address space, or olddelta points to a region of the process' allocated address space that is not writable.

The calling process does not have an effective user ID of 0.


linking library

Differences between versions

The high-precision system clock that is implemented on SCO OpenServer Release 5.0.6 and later releases improves the precision of adjtime( ). When using adjtime( ) on earlier releases that do not support the high-precision system clock, do not call the <sys/clock.h> header file.

See also

clock(HW), date(C), gettimeofday(S), settimeofday(S), stime(S)

Standards conformance

adjtime is conformant with:

AT&T SVID Issue 3.

© 2003 System Services (S)
SCO OpenServer Release 5.0.7 -- 11 February 2003