[ntp:questions] Re: adjtime limited to 2145 seconds?

Richard B. Gilbert rgilbert88 at comcast.net
Thu Jan 5 04:34:08 UTC 2006


Santashil PalChaudhuri wrote:

>Hi,
>
>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.
>
>Regards
>Santa
>
>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;
>
>    adj.tv_sec=1;
>    adj.tv_usec=500000;
>
>    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;
>
>  
>
I'd suggest using the date command to set the clock within a minute or 
two of the correct time.  You should then have no problem making a small 
correction with adjtime() or ntpdate.




More information about the questions mailing list