[ntp:questions] adjtime limited to 2145 seconds?

Santashil PalChaudhuri santapc at gmail.com
Thu Jan 5 00:35:28 UTC 2006


Below I give a code snippet, for using adjtime() on my redhat system.
The maximum delta allowed is +/- 2145 seconds. If I give bigger than
this, then I get a EINVAL error no 22 as the delta is greater than the
maximum allowed. Is this normal?

I was trying to use "ntpdate -B <server>" which uses the adjtime always
and that gives a "Can't adjust the time of day: Invalid argument"
because of this adjtime error.

Any comments will be appreciated.


run the following as root....
#include <sys/time.h>
#include <stdio.h>
#include <errno.h>

int main(int argc, char *argv[])
    struct timeval adj, old;
    int rc;


    rc=adjtime(&adj, &old);
    if(rc==0) {
        printf("adjtime() successful. "
               "Olddelta = %u.%06u\n",
                old.tv_sec, old.tv_usec);
    else {
        printf("adjtime() failed, errno = %d\n",errno);
        return -1;

    return 0;

More information about the questions mailing list