1ADJTIME(3) Linux Programmer's Manual ADJTIME(3)
2
3
4
6 adjtime - correct the time to synchronize the system clock
7
9 #include <sys/time.h>
10
11 int adjtime(const struct timeval *delta, struct timeval *olddelta);
12
13 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
14
15 adjtime():
16 Since glibc 2.19:
17 _DEFAULT_SOURCE
18 Glibc 2.19 and earlier:
19 _BSD_SOURCE
20
22 The adjtime() function gradually adjusts the system clock (as returned
23 by gettimeofday(2)). The amount of time by which the clock is to be
24 adjusted is specified in the structure pointed to by delta. This
25 structure has the following form:
26
27 struct timeval {
28 time_t tv_sec; /* seconds */
29 suseconds_t tv_usec; /* microseconds */
30 };
31
32 If the adjustment in delta is positive, then the system clock is
33 speeded up by some small percentage (i.e., by adding a small amount of
34 time to the clock value in each second) until the adjustment has been
35 completed. If the adjustment in delta is negative, then the clock is
36 slowed down in a similar fashion.
37
38 If a clock adjustment from an earlier adjtime() call is already in
39 progress at the time of a later adjtime() call, and delta is not NULL
40 for the later call, then the earlier adjustment is stopped, but any al‐
41 ready completed part of that adjustment is not undone.
42
43 If olddelta is not NULL, then the buffer that it points to is used to
44 return the amount of time remaining from any previous adjustment that
45 has not yet been completed.
46
48 On success, adjtime() returns 0. On failure, -1 is returned, and errno
49 is set to indicate the error.
50
52 EINVAL The adjustment in delta is outside the permitted range.
53
54 EPERM The caller does not have sufficient privilege to adjust the
55 time. Under Linux, the CAP_SYS_TIME capability is required.
56
58 For an explanation of the terms used in this section, see at‐
59 tributes(7).
60
61 ┌────────────────────────────────────────────┬───────────────┬─────────┐
62 │Interface │ Attribute │ Value │
63 ├────────────────────────────────────────────┼───────────────┼─────────┤
64 │adjtime() │ Thread safety │ MT-Safe │
65 └────────────────────────────────────────────┴───────────────┴─────────┘
66
68 4.3BSD, System V.
69
71 The adjustment that adjtime() makes to the clock is carried out in such
72 a manner that the clock is always monotonically increasing. Using adj‐
73 time() to adjust the time prevents the problems that can be caused for
74 certain applications (e.g., make(1)) by abrupt positive or negative
75 jumps in the system time.
76
77 adjtime() is intended to be used to make small adjustments to the sys‐
78 tem time. Most systems impose a limit on the adjustment that can be
79 specified in delta. In the glibc implementation, delta must be less
80 than or equal to (INT_MAX / 1000000 - 2) and greater than or equal to
81 (INT_MIN / 1000000 + 2) (respectively 2145 and -2145 seconds on i386).
82
84 A longstanding bug meant that if delta was specified as NULL, no valid
85 information about the outstanding clock adjustment was returned in old‐
86 delta. (In this circumstance, adjtime() should return the outstanding
87 clock adjustment, without changing it.) This bug is fixed on systems
88 with glibc 2.8 or later and Linux kernel 2.6.26 or later.
89
91 adjtimex(2), gettimeofday(2), time(7)
92
94 This page is part of release 5.13 of the Linux man-pages project. A
95 description of the project, information about reporting bugs, and the
96 latest version of this page, can be found at
97 https://www.kernel.org/doc/man-pages/.
98
99
100
101Linux 2021-03-22 ADJTIME(3)