1<?xml version='1.0'?> <!--*-nxml-*-->
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6<refentry id="timedatectl" conditional='ENABLE_TIMEDATECTL'
7  xmlns:xi="http://www.w3.org/2001/XInclude">
8
9  <refentryinfo>
10    <title>timedatectl</title>
11    <productname>systemd</productname>
12  </refentryinfo>
13
14  <refmeta>
15    <refentrytitle>timedatectl</refentrytitle>
16    <manvolnum>1</manvolnum>
17  </refmeta>
18
19  <refnamediv>
20    <refname>timedatectl</refname>
21    <refpurpose>Control the system time and date</refpurpose>
22  </refnamediv>
23
24  <refsynopsisdiv>
25    <cmdsynopsis>
26      <command>timedatectl</command>
27      <arg choice="opt" rep="repeat">OPTIONS</arg>
28      <arg choice="req">COMMAND</arg>
29    </cmdsynopsis>
30  </refsynopsisdiv>
31
32  <refsect1>
33    <title>Description</title>
34
35    <para><command>timedatectl</command> may be used to query and change the system clock and its settings,
36    and enable or disable time synchronization services.</para>
37
38    <para>Use
39    <citerefentry><refentrytitle>systemd-firstboot</refentrytitle><manvolnum>1</manvolnum></citerefentry>
40    to initialize the system time zone for mounted (but not booted)
41    system images.</para>
42
43    <para><command>timedatectl</command> may be used to show the current status of time synchronization
44    services, for example
45    <citerefentry><refentrytitle>systemd-timesyncd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
46    </para>
47
48  </refsect1>
49
50  <refsect1>
51    <title>Commands</title>
52
53    <para>The following commands are understood:</para>
54
55    <variablelist>
56      <varlistentry>
57        <term><command>status</command></term>
58
59        <listitem><para>Show current settings of the system clock and RTC, including whether network time
60        synchronization is active. If no command is specified, this is the implied default.
61        </para></listitem>
62      </varlistentry>
63
64      <varlistentry>
65        <term><command>show</command></term>
66
67        <listitem><para>Show the same information as <option>status</option>, but in machine readable form.
68        This command is intended to be used whenever computer-parsable output is required.
69        Use <option>status</option> if you are looking for formatted human-readable output.</para>
70        <para>By default, empty properties are suppressed. Use <option>--all</option> to show those too.
71        To select specific properties to show, use <option>--property=</option>.</para></listitem>
72      </varlistentry>
73
74      <varlistentry>
75        <term><command>set-time [TIME]</command></term>
76
77        <listitem><para>Set the system clock to the specified time.
78        This will also update the RTC time accordingly. The time may
79        be specified in the format "2012-10-30
80        18:17:16".</para></listitem>
81      </varlistentry>
82
83      <varlistentry>
84        <term><command>set-timezone [TIMEZONE]</command></term>
85
86        <listitem><para>Set the system time zone to the specified
87        value. Available timezones can be listed with
88        <command>list-timezones</command>. If the RTC is configured to
89        be in the local time, this will also update the RTC time. This
90        call will alter the <filename>/etc/localtime</filename>
91        symlink. See
92        <citerefentry><refentrytitle>localtime</refentrytitle><manvolnum>5</manvolnum></citerefentry>
93        for more information.</para></listitem>
94      </varlistentry>
95
96      <varlistentry>
97        <term><command>list-timezones</command></term>
98
99        <listitem><para>List available time zones, one per line.
100        Entries from the list can be set as the system timezone with
101        <command>set-timezone</command>.</para></listitem>
102      </varlistentry>
103
104      <varlistentry>
105        <term><command>set-local-rtc [BOOL]</command></term>
106
107        <listitem><para>Takes a boolean argument. If
108        <literal>0</literal>, the system is configured to maintain the
109        RTC in universal time. If <literal>1</literal>, it will
110        maintain the RTC in local time instead. Note that maintaining
111        the RTC in the local timezone is not fully supported and will
112        create various problems with time zone changes and daylight
113        saving adjustments. If at all possible, keep the RTC in UTC
114        mode. Note that invoking this will also synchronize the RTC
115        from the system clock, unless
116        <option>--adjust-system-clock</option> is passed (see above).
117        This command will change the 3rd line of
118        <filename>/etc/adjtime</filename>, as documented in
119        <citerefentry project='man-pages'><refentrytitle>hwclock</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
120        </para></listitem>
121      </varlistentry>
122
123      <varlistentry>
124        <term><command>set-ntp [BOOL]</command></term>
125
126        <listitem><para>Takes a boolean argument. Controls whether network time synchronization is active and
127        enabled (if available). If the argument is true, this enables and starts the first existing network
128        synchronization service. If the argument is false, then this disables and stops the known network
129        synchronization services. The way that the list of services is built is described in
130        <citerefentry><refentrytitle>systemd-timedated.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
131        </para></listitem>
132      </varlistentry>
133
134    </variablelist>
135
136    <refsect2>
137      <title>systemd-timesyncd Commands</title>
138
139      <para>The following commands are specific to
140      <citerefentry><refentrytitle>systemd-timesyncd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
141      </para>
142
143      <variablelist>
144        <varlistentry>
145          <term><command>timesync-status</command></term>
146
147          <listitem><para>Show current status of
148          <citerefentry><refentrytitle>systemd-timesyncd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
149          If <option>--monitor</option> is specified, then this will monitor the status updates.</para></listitem>
150        </varlistentry>
151
152        <varlistentry>
153          <term><command>show-timesync</command></term>
154
155          <listitem><para>Show the same information as <option>timesync-status</option>, but in machine readable form.
156          This command is intended to be used whenever computer-parsable output is required.
157          Use <option>timesync-status</option> if you are looking for formatted human-readable output.</para>
158          <para>By default, empty properties are suppressed. Use <option>--all</option> to show those too.
159          To select specific properties to show, use <option>--property=</option>.</para></listitem>
160        </varlistentry>
161
162        <varlistentry>
163          <term><command>ntp-servers <replaceable>INTERFACE</replaceable> <replaceable>SERVER</replaceable>…</command></term>
164
165          <listitem><para>Set the interface specific NTP servers. This command can be used only when the
166          interface is managed by <command>systemd-networkd</command>.</para></listitem>
167        </varlistentry>
168
169        <varlistentry>
170          <term><command>revert <replaceable>INTERFACE</replaceable></command></term>
171
172          <listitem><para>Revert the interface specific NTP servers. This command can be used only when
173          the interface is managed by <command>systemd-networkd</command>.</para></listitem>
174        </varlistentry>
175      </variablelist>
176
177    </refsect2>
178
179  </refsect1>
180
181  <refsect1>
182    <title>Options</title>
183
184    <para>The following options are understood:</para>
185
186    <variablelist>
187      <varlistentry>
188        <term><option>--no-ask-password</option></term>
189
190        <listitem><para>Do not query the user for authentication for
191        privileged operations.</para></listitem>
192      </varlistentry>
193
194      <varlistentry>
195        <term><option>--adjust-system-clock</option></term>
196
197        <listitem><para>If <command>set-local-rtc</command> is invoked
198        and this option is passed, the system clock is synchronized
199        from the RTC again, taking the new setting into account.
200        Otherwise, the RTC is synchronized from the system
201        clock.</para></listitem>
202      </varlistentry>
203
204      <varlistentry>
205        <term><option>--monitor</option></term>
206
207        <listitem><para>If <command>timesync-status</command> is invoked and this option is passed, then
208        <command>timedatectl</command> monitors the status of
209        <citerefentry><refentrytitle>systemd-timesyncd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
210        and updates the outputs. Use <keycombo><keycap>Ctrl</keycap><keycap>C</keycap></keycombo> to terminate the
211        monitoring.</para></listitem>
212      </varlistentry>
213
214      <varlistentry>
215        <term><option>-a</option></term>
216        <term><option>--all</option></term>
217
218        <listitem><para>When showing properties of
219        <citerefentry><refentrytitle>systemd-timesyncd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
220        show all properties regardless of whether they are set or not.</para></listitem>
221      </varlistentry>
222
223      <varlistentry>
224        <term><option>-p</option></term>
225        <term><option>--property=</option></term>
226
227        <listitem><para>When showing properties of
228        <citerefentry><refentrytitle>systemd-timesyncd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
229        limit display to certain properties as specified as argument. If not specified, all set properties are shown.
230        The argument should be a property name, such as <literal>ServerName</literal>. If specified more than once,
231        all properties with the specified names are shown.</para></listitem>
232      </varlistentry>
233
234      <varlistentry>
235        <term><option>--value</option></term>
236
237        <listitem>
238          <para>When printing properties with <command>show-timesync</command>, only print the value, and skip the
239          property name and <literal>=</literal>.</para></listitem>
240      </varlistentry>
241
242      <xi:include href="user-system-options.xml" xpointer="host" />
243      <xi:include href="user-system-options.xml" xpointer="machine" />
244
245      <xi:include href="standard-options.xml" xpointer="help" />
246      <xi:include href="standard-options.xml" xpointer="version" />
247      <xi:include href="standard-options.xml" xpointer="no-pager" />
248    </variablelist>
249  </refsect1>
250
251  <refsect1>
252    <title>Exit status</title>
253
254    <para>On success, 0 is returned, a non-zero failure code otherwise.</para>
255  </refsect1>
256
257  <xi:include href="common-variables.xml" />
258
259  <refsect1>
260    <title>Examples</title>
261    <para>Show current settings:
262    <programlisting>$ timedatectl
263               Local time: Thu 2017-09-21 16:08:56 CEST
264           Universal time: Thu 2017-09-21 14:08:56 UTC
265                 RTC time: Thu 2017-09-21 14:08:56
266                Time zone: Europe/Warsaw (CEST, +0200)
267System clock synchronized: yes
268              NTP service: active
269          RTC in local TZ: no</programlisting>
270    </para>
271
272    <para>Enable network time synchronization:
273    <programlisting>$ timedatectl set-ntp true
274==== AUTHENTICATING FOR org.freedesktop.timedate1.set-ntp ===
275Authentication is required to control whether network time synchronization shall be enabled.
276Authenticating as: user
277Password: ********
278==== AUTHENTICATION COMPLETE ===</programlisting>
279
280    <programlisting>$ systemctl status systemd-timesyncd.service
281systemd-timesyncd.service - Network Time Synchronization
282   Loaded: loaded (/usr/lib/systemd/system/systemd-timesyncd.service; enabled)
283   Active: active (running) since Mo 2015-03-30 14:20:38 CEST; 5s ago
284     Docs: man:systemd-timesyncd.service(8)
285 Main PID: 595 (systemd-timesyn)
286   Status: "Using Time Server 216.239.38.15:123 (time4.google.com)."
287   CGroup: /system.slice/systemd-timesyncd.service
288           └─595 /usr/lib/systemd/systemd-timesyncd
289…</programlisting>
290    </para>
291
292    <para>Show current status of
293    <citerefentry><refentrytitle>systemd-timesyncd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>:
294    <programlisting>$ timedatectl timesync-status
295       Server: 216.239.38.15 (time4.google.com)
296Poll interval: 1min 4s (min: 32s; max 34min 8s)
297         Leap: normal
298      Version: 4
299      Stratum: 1
300    Reference: GPS
301    Precision: 1us (-20)
302Root distance: 335us (max: 5s)
303       Offset: +316us
304        Delay: 349us
305       Jitter: 0
306 Packet count: 1
307    Frequency: -8.802ppm</programlisting>
308    </para>
309
310  </refsect1>
311
312  <refsect1>
313    <title>See Also</title>
314    <para>
315      <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
316      <citerefentry project='man-pages'><refentrytitle>hwclock</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
317      <citerefentry project='man-pages'><refentrytitle>date</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
318      <citerefentry><refentrytitle>localtime</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
319      <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
320      <citerefentry><refentrytitle>systemd-timedated.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
321      <citerefentry><refentrytitle>systemd-timesyncd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
322      <citerefentry><refentrytitle>systemd-firstboot</refentrytitle><manvolnum>1</manvolnum></citerefentry>
323    </para>
324  </refsect1>
325
326</refentry>
327