source: chapter09/clock.xml@ 4f560248

11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 arm bdubbs/gcc13 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 4f560248 was 4f560248, checked in by Xi Ruoyao <xry111@…>, 3 years ago

clarify that the system "*ctl" commands won't work in chroot

  • Property mode set to 100644
File size: 4.2 KB
RevLine 
[1118b17]1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
6]>
7
[afcfd74]8<sect1 id="ch-config-clock" revision="systemd">
[1118b17]9 <?dbhtml filename="clock.html"?>
10
11 <title>Configuring the system clock</title>
12
[afcfd74]13 <indexterm zone="ch-config-clock">
[1118b17]14 <primary sortas="d-clock">clock</primary>
15 <secondary>configuring</secondary></indexterm>
16
17 <para>This section discusses how to configure the
18 <command>systemd-timedated</command> system service, which configures
[9e7475a]19 the system clock and timezone.</para>
[1118b17]20
21 <para>If you cannot remember whether or not the hardware clock is set to UTC,
22 find out by running the <userinput>hwclock --localtime --show</userinput>
23 command. This will display what the current time is according to the hardware
24 clock. If this time matches whatever your watch says, then the hardware clock is
25 set to local time. If the output from <command>hwclock</command> is not local
26 time, chances are it is set to UTC time. Verify this by adding or subtracting
27 the proper amount of hours for the timezone to the time shown by
28 <command>hwclock</command>. For example, if you are currently in the MST
29 timezone, which is also known as GMT -0700, add seven hours to the local
30 time.</para>
31
32 <para><command>systemd-timedated</command> reads <filename>/etc/adjtime</filename>,
[9e7475a]33 and depending on the contents of the file, sets the clock to either UTC or
[1118b17]34 local time.</para>
35
36 <para>Create the <filename>/etc/adjtime</filename> file with the following contents
37 if your hardware clock is set to local time:</para>
38
[8154126]39<screen><userinput>cat &gt; /etc/adjtime &lt;&lt; "EOF"
[1118b17]40<literal>0.0 0 0.0
410
42LOCAL</literal>
43EOF</userinput></screen>
44
45 <para>If <filename>/etc/adjtime</filename> isn't present at first boot,
46 <command>systemd-timedated</command> will assume that hardware clock is
47 set to UTC and adjust the file according to that.</para>
48
49 <para>You can also use the <command>timedatectl</command> utility to tell
50 <command>systemd-timedated</command> if your hardware clock is set to
51 UTC or local time:</para>
52
53<screen role="nodump"><userinput>timedatectl set-local-rtc 1</userinput></screen>
54
55 <para><command>timedatectl</command> can also be used to change system time and
56 time zone.</para>
57
58 <para>To change your current system time, issue:</para>
59
60<screen role="nodump"><userinput>timedatectl set-time YYYY-MM-DD HH:MM:SS</userinput></screen>
61
[9e7475a]62 <para>The hardware clock will also be updated accordingly.</para>
[1118b17]63
64 <para>To change your current time zone, issue:</para>
65
66<screen role="nodump"><userinput>timedatectl set-timezone TIMEZONE</userinput></screen>
67
[0d84af1]68 <para>You can get a list of available time zones by running:</para>
[1118b17]69
70<screen role="nodump"><userinput>timedatectl list-timezones</userinput></screen>
71
[4f560248]72 <note><para>Please note that the <command>timedatectl</command> command
73 doesn't work in the chroot environment. It can only
74 be used after the LFS system is booted with systemd.</para></note>
[1118b17]75
76 <sect2>
77 <title>Network Time Synchronization</title>
78
79 <para>Starting with version 213, systemd ships a daemon called
80 <command>systemd-timesyncd</command> which can be used to
81 synchronize the system time with remote NTP servers.</para>
82
83 <para>The daemon is not intended as a replacement for the well
84 established NTP daemon, but as a client only implementation
85 of the SNTP protocol which can be used for less advanced
86 tasks and on resource limited systems.</para>
87
88 <para>Starting with systemd version 216, the
89 <command>systemd-timesyncd</command> daemon is enabled by
90 default. If you want to disable it, issue the following
91 command:</para>
92
93<screen role="nodump"><userinput>systemctl disable systemd-timesyncd</userinput></screen>
94
95 <para>The <filename>/etc/systemd/timesyncd.conf</filename> file
96 can be used to change the NTP servers that
97 <command>systemd-timesyncd</command> synchronizes with.</para>
98
99 <para>Please note that when system clock is set to Local Time,
100 <command>systemd-timesyncd</command> won't update hardware
101 clock.</para>
102
103 </sect2>
104
105</sect1>
Note: See TracBrowser for help on using the repository browser.