241 lines
5.8 KiB
HTML
241 lines
5.8 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of ADJTIME</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>ADJTIME</H1>
|
|
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
adjtime - correct the time to synchronize the system clock
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<PRE>
|
|
<B>#include <<A HREF="file:///usr/include/sys/time.h">sys/time.h</A>></B>
|
|
|
|
<B>int adjtime(const struct timeval *</B><I>delta</I><B>, struct timeval *</B><I>olddelta</I><B>);</B>
|
|
</PRE>
|
|
|
|
<P>
|
|
|
|
|
|
Feature Test Macro Requirements for glibc (see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7)):
|
|
|
|
|
|
<P>
|
|
|
|
<B>adjtime</B>():
|
|
|
|
<BR> Since glibc 2.19:
|
|
<BR> _DEFAULT_SOURCE
|
|
<BR> Glibc 2.19 and earlier:
|
|
<BR> _BSD_SOURCE
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The
|
|
<B>adjtime</B>()
|
|
|
|
function gradually adjusts the system clock (as returned by
|
|
<B><A HREF="/cgi-bin/man/man2html?2+gettimeofday">gettimeofday</A></B>(2)).
|
|
|
|
The amount of time by which the clock is to be adjusted is specified
|
|
in the structure pointed to by
|
|
<I>delta</I>.
|
|
|
|
This structure has the following form:
|
|
<P>
|
|
|
|
|
|
|
|
struct timeval {
|
|
<BR> time_t tv_sec; /* seconds */
|
|
<BR> suseconds_t tv_usec; /* microseconds */
|
|
};
|
|
|
|
|
|
<P>
|
|
|
|
If the adjustment in
|
|
<I>delta</I>
|
|
|
|
is positive, then the system clock is speeded up by some
|
|
small percentage (i.e., by adding a small
|
|
amount of time to the clock value in each second) until the adjustment
|
|
has been completed.
|
|
If the adjustment in
|
|
<I>delta</I>
|
|
|
|
is negative, then the clock is slowed down in a similar fashion.
|
|
<P>
|
|
|
|
If a clock adjustment from an earlier
|
|
<B>adjtime</B>()
|
|
|
|
call is already in progress
|
|
at the time of a later
|
|
<B>adjtime</B>()
|
|
|
|
call, and
|
|
<I>delta</I>
|
|
|
|
is not NULL for the later call, then the earlier adjustment is stopped,
|
|
but any already completed part of that adjustment is not undone.
|
|
<P>
|
|
|
|
If
|
|
<I>olddelta</I>
|
|
|
|
is not NULL, then the buffer that it points to is used to return
|
|
the amount of time remaining from any previous adjustment that
|
|
has not yet been completed.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
On success,
|
|
<B>adjtime</B>()
|
|
|
|
returns 0.
|
|
On failure, -1 is returned, and
|
|
<I>errno</I>
|
|
|
|
is set to indicate the error.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="1"><B>EINVAL</B>
|
|
|
|
<DD>
|
|
The adjustment in
|
|
<I>delta</I>
|
|
|
|
is outside the permitted range.
|
|
<DT id="2"><B>EPERM</B>
|
|
|
|
<DD>
|
|
The caller does not have sufficient privilege to adjust the time.
|
|
Under Linux, the
|
|
<B>CAP_SYS_TIME</B>
|
|
|
|
capability is required.
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>ATTRIBUTES</H2>
|
|
|
|
For an explanation of the terms used in this section, see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
|
|
|
|
<TABLE BORDER>
|
|
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
|
|
<TR VALIGN=top><TD>
|
|
<B>adjtime</B>()
|
|
|
|
</TD><TD>Thread safety</TD><TD>MT-Safe<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<A NAME="lbAH"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
4.3BSD, System V.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
The adjustment that
|
|
<B>adjtime</B>()
|
|
|
|
makes to the clock is carried out in such a manner that the clock
|
|
is always monotonically increasing.
|
|
Using
|
|
<B>adjtime</B>()
|
|
|
|
to adjust the time prevents the problems that can be caused for certain
|
|
applications (e.g.,
|
|
<B><A HREF="/cgi-bin/man/man2html?1+make">make</A></B>(1))
|
|
|
|
by abrupt positive or negative jumps in the system time.
|
|
<P>
|
|
|
|
<B>adjtime</B>()
|
|
|
|
is intended to be used to make small adjustments to the system time.
|
|
Most systems impose a limit on the adjustment that can be specified in
|
|
<I>delta</I>.
|
|
|
|
In the glibc implementation,
|
|
<I>delta</I>
|
|
|
|
must be less than or equal to (INT_MAX / 1000000 - 2)
|
|
and greater than or equal to (INT_MIN / 1000000 + 2)
|
|
(respectively 2145 and -2145 seconds on i386).
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>BUGS</H2>
|
|
|
|
A longstanding bug
|
|
|
|
|
|
meant that if
|
|
<I>delta</I>
|
|
|
|
was specified as NULL,
|
|
no valid information about the outstanding clock adjustment was returned in
|
|
<I>olddelta</I>.
|
|
|
|
(In this circumstance,
|
|
<B>adjtime</B>()
|
|
|
|
should return the outstanding clock adjustment, without changing it.)
|
|
This bug is fixed
|
|
|
|
on systems with glibc 2.8 or later and
|
|
Linux kernel 2.6.26 or later.
|
|
<A NAME="lbAK"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+adjtimex">adjtimex</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+gettimeofday">gettimeofday</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+time">time</A></B>(7)
|
|
|
|
<A NAME="lbAL"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="3"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="4"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="5"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="6"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="7"><A HREF="#lbAF">ERRORS</A><DD>
|
|
<DT id="8"><A HREF="#lbAG">ATTRIBUTES</A><DD>
|
|
<DT id="9"><A HREF="#lbAH">CONFORMING TO</A><DD>
|
|
<DT id="10"><A HREF="#lbAI">NOTES</A><DD>
|
|
<DT id="11"><A HREF="#lbAJ">BUGS</A><DD>
|
|
<DT id="12"><A HREF="#lbAK">SEE ALSO</A><DD>
|
|
<DT id="13"><A HREF="#lbAL">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:35 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|