1ADJTIME(3)                 Linux Programmer's Manual                ADJTIME(3)
2
3
4

NAME

6       adjtime - correct the time to synchronize the system clock
7

SYNOPSIS

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

DESCRIPTION

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
41       already 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

RETURN VALUE

48       On success, adjtime() returns 0.  On failure, -1 is returned, and errno
49       is set to indicate the error.
50

ERRORS

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

ATTRIBUTES

58       For   an   explanation   of   the  terms  used  in  this  section,  see
59       attributes(7).
60
61       ┌──────────┬───────────────┬─────────┐
62Interface Attribute     Value   
63       ├──────────┼───────────────┼─────────┤
64adjtime() │ Thread safety │ MT-Safe │
65       └──────────┴───────────────┴─────────┘

CONFORMING TO

67       4.3BSD, System V.
68

NOTES

70       The adjustment that adjtime() makes to the clock is carried out in such
71       a manner that the clock is always monotonically increasing.  Using adj‐
72       time() to adjust the time prevents the problems that can be caused  for
73       certain  applications  (e.g.,  make(1))  by abrupt positive or negative
74       jumps in the system time.
75
76       adjtime() is intended to be used to make small adjustments to the  sys‐
77       tem  time.   Most  systems impose a limit on the adjustment that can be
78       specified in delta.  In the glibc implementation, delta  must  be  less
79       than  or  equal to (INT_MAX / 1000000 - 2) and greater than or equal to
80       (INT_MIN / 1000000 + 2) (respectively 2145 and -2145 seconds on i386).
81

BUGS

83       A longstanding bug meant that if delta was specified as NULL, no  valid
84       information about the outstanding clock adjustment was returned in old‐
85       delta.  (In this circumstance, adjtime() should return the  outstanding
86       clock  adjustment,  without changing it.)  This bug is fixed on systems
87       with glibc 2.8 or later and Linux kernel 2.6.26 or later.
88

SEE ALSO

90       adjtimex(2), gettimeofday(2), time(7)
91

COLOPHON

93       This page is part of release 4.15 of the Linux  man-pages  project.   A
94       description  of  the project, information about reporting bugs, and the
95       latest    version    of    this    page,    can     be     found     at
96       https://www.kernel.org/doc/man-pages/.
97
98
99
100Linux                             2017-09-15                        ADJTIME(3)
Impressum