1.\" $OpenBSD: adjtime.2,v 1.17 2007/05/31 19:19:32 jmc Exp $ 2.\" $NetBSD: adjtime.2,v 1.5 1995/10/12 15:40:44 jtc Exp $ 3.\" 4.\" Copyright (c) 1980, 1991, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. Neither the name of the University nor the names of its contributors 16.\" may be used to endorse or promote products derived from this software 17.\" without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" @(#)adjtime.2 8.1 (Berkeley) 6/4/93 32.\" 33.Dd $Mdocdate: May 31 2007 $ 34.Dt ADJTIME 2 35.Os 36.Sh NAME 37.Nm adjtime 38.Nd "correct the time to allow synchronization of the system clock" 39.Sh SYNOPSIS 40.Fd #include <sys/time.h> 41.Ft int 42.Fn adjtime "const struct timeval *delta" "struct timeval *olddelta" 43.Sh DESCRIPTION 44.Fn adjtime 45makes small adjustments to the system time, as returned by 46.Xr gettimeofday 2 , 47advancing or retarding it by the time specified by the timeval 48.Fa delta . 49If 50.Fa delta 51is negative, the clock is slowed down by incrementing it more slowly 52than normal until the correction is complete. 53If 54.Fa delta 55is positive, a larger increment than normal is used. 56The skew used to perform the correction is generally a fraction of one percent. 57Thus, the time is always a monotonically increasing function. 58A time correction from an earlier call to 59.Fn adjtime 60may not be finished when 61.Fn adjtime 62is called again. 63If 64.Fa delta 65is null, no adjustment is done. 66If 67.Fa olddelta 68is non-null, the structure pointed to will contain, upon return, the 69number of microseconds still to be corrected from the earlier call. 70.Pp 71This call may be used by time servers that synchronize the clocks 72of computers in a local area network. 73Such time servers would slow down the clocks of some machines 74and speed up the clocks of others to bring them to the average network time. 75.Pp 76Only the superuser may adjust the time using the 77.Fn adjtime 78function. 79.Sh RETURN VALUES 80A return value of 0 indicates that the call succeeded. 81A return value of \-1 indicates that an error occurred, and in this 82case an error code is stored in the global variable 83.Va errno . 84.Sh ERRORS 85.Fn adjtime 86will fail if: 87.Bl -tag -width Er 88.It Bq Er EFAULT 89Either of the arguments point outside the process's allocated address space. 90.It Bq Er EPERM 91The 92.Fn delta 93argument is non-null and the process's effective user ID is not that 94of the superuser. 95.El 96.Sh SEE ALSO 97.Xr date 1 , 98.Xr adjfreq 2 , 99.Xr gettimeofday 2 , 100.Xr ntpd 8 , 101.Xr timed 8 , 102.Xr timedc 8 103.Rs 104.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD" 105.%A R. Gusella 106.%A S. Zatti 107.Re 108.Sh HISTORY 109The 110.Fn adjtime 111function call appeared in 112.Bx 4.3 . 113.Sh CAVEATS 114Other operating systems restrict calling 115.Nm 116to the superuser and might not allow requesting the current 117correction without specifying a new value. 118