]>
Commit | Line | Data |
---|---|---|
c11b1abf | 1 | .\" Copyright (c) 2006 by Michael Kerrisk <mtk.manpages@gmail.com> |
4c5dd869 | 2 | .\" |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
4c5dd869 MK |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
12 | .\" | |
13 | .\" Since the Linux kernel and libraries are constantly changing, this | |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
10d76543 MK |
16 | .\" the use of the information contained herein. The author(s) may not |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
4c5dd869 MK |
20 | .\" |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by | |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
4c5dd869 | 24 | .\" |
4b8c67d9 | 25 | .TH ADJTIME 3 2017-09-15 "Linux" "Linux Programmer's Manual" |
4c5dd869 | 26 | .SH NAME |
d9bfdb9c | 27 | adjtime \- correct the time to synchronize the system clock |
4c5dd869 MK |
28 | .SH SYNOPSIS |
29 | .nf | |
37565883 | 30 | .B #include <sys/time.h> |
68e4db0a | 31 | .PP |
4c5dd869 MK |
32 | .BI "int adjtime(const struct timeval *" delta ", struct timeval *" olddelta ); |
33 | .fi | |
68e4db0a | 34 | .PP |
cc4615cc MK |
35 | .in -4n |
36 | Feature Test Macro Requirements for glibc (see | |
37 | .BR feature_test_macros (7)): | |
38 | .in | |
68e4db0a | 39 | .PP |
cc4615cc | 40 | .BR adjtime (): |
51c612fb MK |
41 | Since glibc 2.19: |
42 | _DEFAULT_SOURCE | |
43 | Glibc 2.19 and earlier: | |
44 | _BSD_SOURCE | |
4c5dd869 MK |
45 | .SH DESCRIPTION |
46 | The | |
47 | .BR adjtime () | |
48 | function gradually adjusts the system clock (as returned by | |
fb186734 | 49 | .BR gettimeofday (2)). |
4c5dd869 MK |
50 | The amount of time by which the clock is to be adjusted is specified |
51 | in the structure pointed to by | |
52 | .IR delta . | |
53 | This structure has the following form: | |
e646a1ba | 54 | .PP |
a08ea57c | 55 | .in +4n |
e646a1ba | 56 | .EX |
4c5dd869 MK |
57 | struct timeval { |
58 | time_t tv_sec; /* seconds */ | |
59 | suseconds_t tv_usec; /* microseconds */ | |
60 | }; | |
b8302363 | 61 | .EE |
a08ea57c | 62 | .in |
4c5dd869 MK |
63 | .PP |
64 | If the adjustment in | |
65 | .I delta | |
8888a90e | 66 | is positive, then the system clock is speeded up by some |
c13182ef MK |
67 | small percentage (i.e., by adding a small |
68 | amount of time to the clock value in each second) until the adjustment | |
4c5dd869 MK |
69 | has been completed. |
70 | If the adjustment in | |
71 | .I delta | |
72 | is negative, then the clock is slowed down in a similar fashion. | |
847e0d88 | 73 | .PP |
8888a90e MK |
74 | If a clock adjustment from an earlier |
75 | .BR adjtime () | |
c13182ef | 76 | call is already in progress |
8888a90e | 77 | at the time of a later |
4c5dd869 MK |
78 | .BR adjtime () |
79 | call, and | |
80 | .I delta | |
c13182ef | 81 | is not NULL for the later call, then the earlier adjustment is stopped, |
8888a90e | 82 | but any already completed part of that adjustment is not undone. |
847e0d88 | 83 | .PP |
4c5dd869 MK |
84 | If |
85 | .I olddelta | |
c13182ef MK |
86 | is not NULL, then the buffer that it points to is used to return |
87 | the amount of time remaining from any previous adjustment that | |
4c5dd869 | 88 | has not yet been completed. |
47297adb | 89 | .SH RETURN VALUE |
2b2581ee MK |
90 | On success, |
91 | .BR adjtime () | |
d72a31c6 MK |
92 | returns 0. |
93 | On failure, \-1 is returned, and | |
2b2581ee MK |
94 | .I errno |
95 | is set to indicate the error. | |
96 | .SH ERRORS | |
97 | .TP | |
98 | .B EINVAL | |
99 | The adjustment in | |
100 | .I delta | |
101 | is outside the permitted range. | |
102 | .TP | |
103 | .B EPERM | |
104 | The caller does not have sufficient privilege to adjust the time. | |
eb9a0b2f | 105 | Under Linux, the |
2b2581ee MK |
106 | .B CAP_SYS_TIME |
107 | capability is required. | |
31047e64 | 108 | .SH ATTRIBUTES |
ebea5af9 MK |
109 | For an explanation of the terms used in this section, see |
110 | .BR attributes (7). | |
111 | .TS | |
112 | allbox; | |
113 | lb lb lb | |
114 | l l l. | |
115 | Interface Attribute Value | |
116 | T{ | |
31047e64 | 117 | .BR adjtime () |
ebea5af9 MK |
118 | T} Thread safety MT-Safe |
119 | .TE | |
2b2581ee MK |
120 | .SH CONFORMING TO |
121 | 4.3BSD, System V. | |
4c5dd869 MK |
122 | .SH NOTES |
123 | The adjustment that | |
124 | .BR adjtime () | |
125 | makes to the clock is carried out in such a manner that the clock | |
126 | is always monotonically increasing. | |
127 | Using | |
128 | .BR adjtime () | |
129 | to adjust the time prevents the problems that can be caused for certain | |
130 | applications (e.g., | |
131 | .BR make (1)) | |
132 | by abrupt positive or negative jumps in the system time. | |
847e0d88 | 133 | .PP |
4c5dd869 MK |
134 | .BR adjtime () |
135 | is intended to be used to make small adjustments to the system time. | |
136 | Most systems impose a limit on the adjustment that can be specified in | |
137 | .IR delta . | |
c13182ef MK |
138 | In the glibc implementation, |
139 | .I delta | |
f262c004 | 140 | must be less than or equal to (INT_MAX / 1000000 \- 2) |
c13182ef | 141 | and greater than or equal to (INT_MIN / 1000000 + 2) |
34ccb744 | 142 | (respectively 2145 and \-2145 seconds on i386). |
e9ec6fc9 | 143 | .SH BUGS |
c246714d MK |
144 | A longstanding bug |
145 | .\" http://sourceware.org/bugzilla/show_bug?id=2449 | |
146 | .\" http://bugzilla.kernel.org/show_bug.cgi?id=6761 | |
147 | meant that if | |
e9ec6fc9 | 148 | .I delta |
c246714d MK |
149 | was specified as NULL, |
150 | no valid information about the outstanding clock adjustment was returned in | |
e9ec6fc9 | 151 | .IR olddelta . |
c13182ef | 152 | (In this circumstance, |
e9ec6fc9 MK |
153 | .BR adjtime () |
154 | should return the outstanding clock adjustment, without changing it.) | |
c246714d | 155 | This bug is fixed |
46bbbb35 | 156 | .\" Thanks to the new adjtimex() ADJ_OFFSET_SS_READ flag |
c246714d MK |
157 | on systems with glibc 2.8 or later and |
158 | Linux kernel 2.6.26 or later. | |
47297adb | 159 | .SH SEE ALSO |
4c5dd869 MK |
160 | .BR adjtimex (2), |
161 | .BR gettimeofday (2), | |
a7e1c01a | 162 | .BR time (7) |