1 .\" Copyright (c) 1995 Michael Chastain (mec@shell.portal.com), 15 April 1995.
2 .\" and Copyright (C) 2014 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
5 .\" This is free documentation; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License as
7 .\" published by the Free Software Foundation; either version 2 of
8 .\" the License, or (at your option) any later version.
10 .\" The GNU General Public License's references to "object code"
11 .\" and "executables" are to be interpreted as the output of any
12 .\" document formatting or typesetting system, including
13 .\" intermediate and printed output.
15 .\" This manual is distributed in the hope that it will be useful,
16 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
17 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 .\" GNU General Public License for more details.
20 .\" You should have received a copy of the GNU General Public
21 .\" License along with this manual; if not, see
22 .\" <http://www.gnu.org/licenses/>.
25 .\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
26 .\" Modified 1997-07-30 by Paul Slootman <paul@wurtel.demon.nl>
27 .\" Modified 2004-05-27 by Michael Kerrisk <mtk.manpages@gmail.com>
29 .TH ADJTIMEX 2 2014-05-28 "Linux" "Linux Programmer's Manual"
31 adjtimex \- tune kernel clock
34 .BR "#define _BSD_SOURCE" " /* See feature_test_macros(7) */"
35 .B #include <sys/timex.h>
37 .BI "int adjtimex(struct timex *" "buf" );
40 Linux uses David L. Mills' clock adjustment algorithm (see RFC\ 1305).
43 reads and optionally sets adjustment parameters for this algorithm.
44 It takes a pointer to a
46 structure, updates kernel parameters from field values,
47 and returns the same structure with current kernel values.
48 This structure is declared as follows:
53 int modes; /* Mode selector */
54 long offset; /* Time offset (microseconds) */
55 long freq; /* Frequency offset, as scaled PPM
56 (parts per million) */
57 .\" FIXME What is the scaling unit of timex.freq? 2^16 ?
58 long maxerror; /* Maximum error (microseconds) */
59 long esterror; /* Estimated error (microseconds) */
60 int status; /* Clock command/status */
61 long constant; /* PLL (phase-lock loop) time constant */
62 long precision; /* Clock precision (microseconds)
64 long tolerance; /* Clock frequency tolerance (PPM)
66 struct timeval time; /* Current time (read-only, except
68 long tick; /* Usecs between clock ticks */
69 long ppsfreq; /* PPS frequency (scaled PPM) (read-only) */
70 long jitter; /* PPS jitter (microseconds)
72 int shift; /* Interval duration (sec) (read-only) */
73 long stabil; /* PPS stability (scaled PPM) (read-only) */
74 long jitcnt; /* Jitter limit exceeded (read-only) */
75 long calcnt; /* Calibration intervals (read-only) */
76 long errcnt; /* Calibration errors (read-only) */
77 long stbcnt; /* Stability limit exceeded (read-only) */
78 int tai; /* TAI offset (sec) (read-only) */
85 field determines which parameters, if any, to set.
86 It is a bit mask containing a
88 combination of zero or more of the following bits:
95 Set frequency offset from
99 Set maximum time error from
103 Set estimated time error from
107 Set clock status from
111 Set PLL time constant from
114 .BR ADJ_SETOFFSET " (since Linux 2.6.29)"
115 .\" commit 094aa1881fdc1b8889b442eb3511b31f3ec2b762
116 .\" Author: Richard Cochran <richardcochran@gmail.com>
122 .BR ADJ_MICRO " (since Linux 2.6.36)"
123 .\" commit eea83d896e318bda54be2d2770d2c5d6668d11db
124 .\" Author: Roman Zippel <zippel@linux-m68k.org>
125 Select microsecond resolution.
127 .BR ADJ_NANO " (since Linux 2.6.36)"
128 .\" commit eea83d896e318bda54be2d2770d2c5d6668d11db
129 .\" Author: Roman Zippel <zippel@linux-m68k.org>
130 Select nanosecond resolution.
137 .BR ADJ_TAI " (since Linux 2.6.26)"
146 can be specified as either of the following values,
147 in which case other bits in
151 .BR ADJ_OFFSET_SINGLESHOT
152 .\" In user space, ADJ_OFFSET_SINGLESHOT is 0x8001
153 .\" In kernel space it is 0x0001, and must be ANDed with ADJ_ADJTIME (0x8000)
156 (gradually) adjust time by value specified in
158 which specifies an adjustment in microseconds.
160 .BR ADJ_OFFSET_SS_READ " (functional since Linux 2.6.28)"
161 .\" In user space, ADJ_OFFSET_SS_READ is 0xa001
162 .\" In kernel space there is ADJ_OFFSET_READONLY (0x2000) anded with
163 .\" ADJ_ADJTIME (0x8000) and ADJ_OFFSET_SINGLESHOT (0x0001) to give 0xa001)
166 the remaining amount of time to be adjusted after an earlier
167 .BR ADJ_OFFSET_SINGLESHOT
169 This feature was added in Linux 2.6.24,
170 .\" commit 52bfb36050c8529d9031d2c2513b281a360922ec
171 but did not work correctly
172 .\" commit 916c7a855174e3b53d182b97a26b2e27a29726a1
175 Ordinary users are restricted to a value of either 0 or
176 .B ADJ_OFFSET_SS_READ
179 Only the superuser may set any parameters.
185 is read-only, the new value is passed through
189 should not be used in conjunction with
191 since the latter mode also employs the
195 Support for TAI (Atomic International Time)
197 .\" commit 153b5d054ac2d98ea0d86504884326b6777f683d
199 For a complete explanation of TAI
200 and the difference between TAI and UTC, see
201 .UR http://www.bipm.org/en/bipm/tai/tai.html
207 returns the clock state; that is, one of the following values:
219 Leap second in progress.
222 Leap second has occurred.
225 Clock not synchronized.
235 does not point to writable memory.
238 An attempt was made to set
240 to a value outside the range \-131071 to +131071,
243 to a value other than those listed above,
246 to a value outside the range
252 is the system timer interrupt frequency.
257 .BR ADJ_OFFSET_SS_READ ,
258 and the caller does not have sufficient privilege.
261 capability is required.
264 is Linux-specific and should not be used in programs
265 intended to be portable.
268 for a more portable, but less flexible,
269 method of adjusting the system clock.
271 .BR settimeofday (2),
273 .BR capabilities (7),