1.\" $OpenBSD: adjtime.2,v 1.20 2013/08/14 06:32:28 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: August 14 2013 $ 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. 70Setting the time with 71.Xr settimeofday 2 72will cancel any in-progress time adjustment. 73.Pp 74This call may be used by time servers that synchronize the clocks 75of computers in a local area network. 76Such time servers would slow down the clocks of some machines 77and speed up the clocks of others to bring them to the average network time. 78.Pp 79Only the superuser may adjust the time using the 80.Fn adjtime 81function. 82.Sh RETURN VALUES 83A return value of 0 indicates that the call succeeded. 84A return value of \-1 indicates that an error occurred, and in this 85case an error code is stored in the global variable 86.Va errno . 87.Sh ERRORS 88.Fn adjtime 89will fail if: 90.Bl -tag -width Er 91.It Bq Er EFAULT 92Either of the arguments point outside the process's allocated address space. 93.It Bq Er EPERM 94The 95.Fn delta 96argument is non-null and the process's effective user ID is not that 97of the superuser. 98.El 99.Sh SEE ALSO 100.Xr date 1 , 101.Xr adjfreq 2 , 102.Xr gettimeofday 2 , 103.Xr ntpd 8 104.Sh HISTORY 105The 106.Fn adjtime 107function call appeared in 108.Bx 4.3 . 109.Sh CAVEATS 110Other operating systems restrict calling 111.Nm 112to the superuser and might not allow requesting the current 113correction without specifying a new value. 114