1.\" $OpenBSD: adjtime.2,v 1.25 2019/03/26 16:02:54 cheloha 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: March 26 2019 $ 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.In 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 66.Dv NULL , 67no adjustment is done. 68If 69.Fa olddelta 70is 71.Pf non- Dv NULL , 72the number of microseconds still to be corrected from the earlier call 73is stored into 74.Pf * Fa olddelta . 75Setting the time with 76.Xr settimeofday 2 77cancels any in-progress time adjustment. 78.Pp 79This call may be used by time servers that synchronize the clocks 80of computers in a local area network. 81Such time servers would slow down the clocks of some machines 82and speed up the clocks of others to bring them to the average network time. 83.Pp 84Only the superuser may adjust the time using the 85.Fn adjtime 86function. 87.Sh RETURN VALUES 88.Rv -std 89.Sh ERRORS 90.Fn adjtime 91will fail if: 92.Bl -tag -width Er 93.It Bq Er EFAULT 94Either of the arguments point outside the process's allocated address space. 95.It Bq Er EINVAL 96The 97.Fa delta 98argument is 99.Pf non- Dv NULL 100and specifies a microsecond value less than zero or 101greater than or equal to one million. 102.It Bq Er EINVAL 103The 104.Fa delta 105argument is 106.Pf non- Dv NULL 107and represents an adjustment greater than 108.Dv INT64_MAX 109microseconds or less than 110.Dv INT64_MIN 111microseconds. 112.It Bq Er EPERM 113The 114.Fa delta 115argument is 116.Pf non- Dv NULL 117and the process's effective user ID is not that of the superuser. 118.El 119.Sh SEE ALSO 120.Xr date 1 , 121.Xr adjfreq 2 , 122.Xr gettimeofday 2 , 123.Xr ntpd 8 124.Sh HISTORY 125The 126.Fn adjtime 127function call appeared in 128.Bx 4.3 . 129.Sh CAVEATS 130Other operating systems restrict calling 131.Fn adjtime 132to the superuser and might not allow requesting the current 133correction without specifying a new value. 134