1 .\" Copyright (c) 1995 Michael Chastain (mec@shell.portal.com), 15 April 1995.
3 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
9 .\" The GNU General Public License's references to "object code"
10 .\" and "executables" are to be interpreted as the output of any
11 .\" document formatting or typesetting system, including
12 .\" intermediate and printed output.
14 .\" This manual is distributed in the hope that it will be useful,
15 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 .\" GNU General Public License for more details.
19 .\" You should have received a copy of the GNU General Public
20 .\" License along with this manual; if not, see
21 .\" <http://www.gnu.org/licenses/>.
24 .\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
25 .\" Modified 1997-07-30 by Paul Slootman <paul@wurtel.demon.nl>
26 .\" Modified 2004-05-27 by Michael Kerrisk <mtk.manpages@gmail.com>
28 .\" FIXME Document ADJ_MICRO and ADJ_NANO (added in Linux 2.6.26)
29 .\" commit eea83d896e318bda54be2d2770d2c5d6668d11db
30 .\" Author: Roman Zippel <zippel@linux-m68k.org>
32 .\" FIXME Document ADJ_SETOFFSET (added in Linux 2.6.39)
33 .\" commit 094aa1881fdc1b8889b442eb3511b31f3ec2b762
34 .\" Author: Richard Cochran <richardcochran@gmail.com>
36 .TH ADJTIMEX 2 2014-05-28 "Linux" "Linux Programmer's Manual"
38 adjtimex \- tune kernel clock
41 .BR "#define _BSD_SOURCE" " /* See feature_test_macros(7) */"
42 .B #include <sys/timex.h>
44 .BI "int adjtimex(struct timex *" "buf" );
47 Linux uses David L. Mills' clock adjustment algorithm (see RFC\ 1305).
50 reads and optionally sets adjustment parameters for this algorithm.
51 It takes a pointer to a
53 structure, updates kernel parameters from field values,
54 and returns the same structure with current kernel values.
55 This structure is declared as follows:
60 int modes; /* mode selector */
61 long offset; /* time offset (usec) */
62 long freq; /* frequency offset (scaled ppm) */
63 .\" FIXME What is the scaling unit of timex.freq? 2^16 ?
64 long maxerror; /* maximum error (usec) */
65 long esterror; /* estimated error (usec) */
66 int status; /* clock command/status */
67 long constant; /* pll time constant */
68 long precision; /* clock precision (usec) (read-only) */
69 long tolerance; /* clock frequency tolerance (ppm)
71 struct timeval time; /* current time (read-only) */
72 long tick; /* usecs between clock ticks */
73 long ppsfreq; /* pps frequency (scaled ppm) (read-only) */
74 long jitter; /* pps jitter (usec) (read-only) */
75 int shift; /* interval duration (sec) (read-only) */
76 long stabil; /* pps stability (scaled ppm) (read-only) */
77 long jitcnt; /* jitter limit exceeded (read-only) */
78 long calcnt; /* calibration intervals (read-only) */
79 long errcnt; /* calibration errors (read-only) */
80 long stbcnt; /* stability limit exceeded (read-only) */
81 int tai; /* TAI offset (sec) (read-only) */
88 field determines which parameters, if any, to set.
91 combination of zero or more of the following bits:
95 #define ADJ_OFFSET 0x0001 /* time offset */
96 #define ADJ_FREQUENCY 0x0002 /* frequency offset */
97 #define ADJ_MAXERROR 0x0004 /* maximum time error */
98 #define ADJ_ESTERROR 0x0008 /* estimated time error */
99 #define ADJ_STATUS 0x0010 /* clock status */
100 #define ADJ_TIMECONST 0x0020 /* pll time constant */
101 #define ADJ_TAI 0x0080 /* TAI offset (since Linux 2.6.26) */
102 #define ADJ_TICK 0x4000 /* tick value */
103 #define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime() */
107 Ordinary users are restricted to a zero value for
109 Only the superuser may set any parameters.
115 is read-only, the new value is passed through
119 should not be used in conjunction with
121 since the latter mode also employs the
125 Support for TAI (Atomic International Time)
127 .\" commit 153b5d054ac2d98ea0d86504884326b6777f683d
129 For a complete explanation of TAI
130 and the difference between TAI and UTC, see
131 .UR http://www.bipm.org/en/bipm/tai/tai.html
137 returns the clock state:
141 #define TIME_OK 0 /* clock synchronized */
142 #define TIME_INS 1 /* insert leap second */
143 #define TIME_DEL 2 /* delete leap second */
144 #define TIME_OOP 3 /* leap second in progress */
145 #define TIME_WAIT 4 /* leap second has occurred */
146 #define TIME_BAD 5 /* clock not synchronized */
158 does not point to writable memory.
161 An attempt is made to set
163 to a value outside the range \-131071 to +131071,
166 to a value other than those listed above,
169 to a value outside the range
175 is the system timer interrupt frequency.
179 is nonzero and the caller does not have sufficient privilege.
182 capability is required.
185 is Linux-specific and should not be used in programs
186 intended to be portable.
189 for a more portable, but less flexible,
190 method of adjusting the system clock.
192 .BR settimeofday (2),
194 .BR capabilities (7),