|
@@ -1,4 +1,4 @@
|
|
|
-<?xml version="1.0" encoding="ISO-8859-1"?>
|
|
|
+<?xml version="1.0" encoding="UTF-8"?>
|
|
|
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
|
|
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
|
|
<!ENTITY % general-entities SYSTEM "../general.ent">
|
|
@@ -8,18 +8,20 @@
|
|
|
<sect1 id="ch-scripts-clock" revision="systemd">
|
|
|
<?dbhtml filename="clock.html"?>
|
|
|
|
|
|
- <title>Configuring the system clock</title>
|
|
|
+ <title>配置系统时钟</title>
|
|
|
|
|
|
<indexterm zone="ch-scripts-clock">
|
|
|
<primary sortas="d-clock">clock</primary>
|
|
|
<secondary>configuring</secondary></indexterm>
|
|
|
|
|
|
- <para>This section discusses how to configure the
|
|
|
+ <!--para>This section discusses how to configure the
|
|
|
<command>systemd-timedated</command> system service, which configures
|
|
|
- system clock and timezone.</para>
|
|
|
+ system clock and timezone.</para-->
|
|
|
+ <para>本节讨论如何配置 <command>systemd-timedated</command> 系统服务,
|
|
|
+ 它的作用是配置系统时钟和时区。</para>
|
|
|
|
|
|
- <para>If you cannot remember whether or not the hardware clock is set to UTC,
|
|
|
- find out by running the <userinput>hwclock --localtime --show</userinput>
|
|
|
+ <!--para>If you cannot remember whether or not the hardware clock is set to UTC,
|
|
|
+ find out by running the <userinput>hwclock localtime show</userinput>
|
|
|
command. This will display what the current time is according to the hardware
|
|
|
clock. If this time matches whatever your watch says, then the hardware clock is
|
|
|
set to local time. If the output from <command>hwclock</command> is not local
|
|
@@ -27,14 +29,31 @@
|
|
|
the proper amount of hours for the timezone to the time shown by
|
|
|
<command>hwclock</command>. For example, if you are currently in the MST
|
|
|
timezone, which is also known as GMT -0700, add seven hours to the local
|
|
|
- time.</para>
|
|
|
-
|
|
|
- <para><command>systemd-timedated</command> reads <filename>/etc/adjtime</filename>,
|
|
|
- and depending on the contents of the file, it sets the clock to either UTC or
|
|
|
- local time.</para>
|
|
|
-
|
|
|
- <para>Create the <filename>/etc/adjtime</filename> file with the following contents
|
|
|
- if your hardware clock is set to local time:</para>
|
|
|
+ time.</para-->
|
|
|
+ <para>如果您不确定您的硬件时钟是否设置为 UTC ,运行
|
|
|
+ <userinput>hwclock --localtime --show</userinput> 命令,
|
|
|
+ 它会显示硬件时钟给出的当前时间。如果这个时间和您的手表显示的一致,
|
|
|
+ 则说明硬件时钟被设定为本地时间。相反,如果 <command>hwclock</command>
|
|
|
+ 输出的时间不是本地时间,则硬件时钟很可能被设定为 UTC 时间。
|
|
|
+ 根据您的时区,在 <command>hwclock</command>
|
|
|
+ 显示的时间上加减对应的小时数,进行进一步的验证。
|
|
|
+ 例如,如果您现在处于莫斯科时区,即 GMT -0700 ,在本地时间上加
|
|
|
+ 7 小时,再进行比较。</para>
|
|
|
+
|
|
|
+ <note><title>译注</title>
|
|
|
+ <para>Windows 会将硬件时钟设定为本地时间,因此如果您要同时安装
|
|
|
+ Windows 和 Linux,就要将 Linux (包括 LFS 和其他发行版)
|
|
|
+ 配置为使用本地时间,除非能够忍受 Windows 和 Linux 显示的不同时间
|
|
|
+ (必有一个是错误的)。
|
|
|
+ </para>
|
|
|
+ </note>
|
|
|
+
|
|
|
+ <para><command>systemd-timedated</command> 读取
|
|
|
+ <filename>/etc/adjtime</filename>,
|
|
|
+ 并根据其内容将硬件时钟设定为 UTC 或本地时间。</para>
|
|
|
+
|
|
|
+ <para>如果您的硬件时钟设置为本地时间,以下列内容创建
|
|
|
+ <filename>/etc/adjtime</filename> 文件:</para>
|
|
|
|
|
|
<screen role="nodump"><userinput>cat > /etc/adjtime << "EOF"
|
|
|
<literal>0.0 0 0.0
|
|
@@ -42,62 +61,83 @@
|
|
|
LOCAL</literal>
|
|
|
EOF</userinput></screen>
|
|
|
|
|
|
- <para>If <filename>/etc/adjtime</filename> isn't present at first boot,
|
|
|
- <command>systemd-timedated</command> will assume that hardware clock is
|
|
|
- set to UTC and adjust the file according to that.</para>
|
|
|
+ <para>如果 <filename>/etc/adjtime</filename> 在初次引导时不存在,
|
|
|
+ <command>systemd-timedated</command> 会假设硬件时钟使用 UTC ,
|
|
|
+ 并据此调整该文件。</para>
|
|
|
|
|
|
- <para>You can also use the <command>timedatectl</command> utility to tell
|
|
|
- <command>systemd-timedated</command> if your hardware clock is set to
|
|
|
- UTC or local time:</para>
|
|
|
+ <para>您也可以使用 <command>timedatectl</command> 工具告诉
|
|
|
+ <command>systemd-timedated</command> 您的硬件时钟是 UTC 还是本地时间:
|
|
|
+ </para>
|
|
|
|
|
|
<screen role="nodump"><userinput>timedatectl set-local-rtc 1</userinput></screen>
|
|
|
|
|
|
- <para><command>timedatectl</command> can also be used to change system time and
|
|
|
- time zone.</para>
|
|
|
+ <para><command>timedatectl</command> 也能修改系统时间和时区。</para>
|
|
|
|
|
|
- <para>To change your current system time, issue:</para>
|
|
|
+ <para>如果要修改系统时间,执行以下命令:</para>
|
|
|
|
|
|
<screen role="nodump"><userinput>timedatectl set-time YYYY-MM-DD HH:MM:SS</userinput></screen>
|
|
|
|
|
|
- <para>Hardware clock will also be updated accordingly.</para>
|
|
|
+ <para>硬件时钟也会同时被更新。</para>
|
|
|
|
|
|
- <para>To change your current time zone, issue:</para>
|
|
|
+ <para>要修改当前时区,执行以下命令:</para>
|
|
|
|
|
|
<screen role="nodump"><userinput>timedatectl set-timezone TIMEZONE</userinput></screen>
|
|
|
|
|
|
- <para>You can get a list of available time zones by running:</para>
|
|
|
+ <para>您可以通过运行以下命令查看可用的时区列表:</para>
|
|
|
|
|
|
<screen role="nodump"><userinput>timedatectl list-timezones</userinput></screen>
|
|
|
|
|
|
- <note><para>Please note that the <command>timedatectl</command> command can
|
|
|
- be used only on a system booted with systemd.</para></note>
|
|
|
+ <note><para>注意 <command>timedatectl</command> 命令只能用于
|
|
|
+ systemd 引导的系统。</para></note>
|
|
|
|
|
|
+ <note><title>译注</title>
|
|
|
+ <para><command>timedatectl</command> 在 chroot 环境中无法使用,
|
|
|
+ 如果需要重新设定系统时间,要么在引导进入 LFS 系统后再使用
|
|
|
+ <command>timedatectl</command> ,要么使用传统的
|
|
|
+ <command>hwclock --set</command> 命令。系统时区可以按照
|
|
|
+ <xref linkend="conf-zone"/> 中的方法设置。</para>
|
|
|
+ </note>
|
|
|
<sect2>
|
|
|
- <title>Network Time Synchronization</title>
|
|
|
+ <title>网络时钟同步</title>
|
|
|
|
|
|
- <para>Starting with version 213, systemd ships a daemon called
|
|
|
+ <!--para>Starting with version 213, systemd ships a daemon called
|
|
|
<command>systemd-timesyncd</command> which can be used to
|
|
|
- synchronize the system time with remote NTP servers.</para>
|
|
|
+ synchronize the system time with remote NTP servers.</para-->
|
|
|
+ <para>从版本 213 开始,systemd 附带了一个名为
|
|
|
+ <command>systemd-timesyncd</command> 的守护进程,
|
|
|
+ 可以用于将系统时间与远程 NTP 服务器同步。</para>
|
|
|
|
|
|
- <para>The daemon is not intended as a replacement for the well
|
|
|
+ <!--para>The daemon is not intended as a replacement for the well
|
|
|
established NTP daemon, but as a client only implementation
|
|
|
of the SNTP protocol which can be used for less advanced
|
|
|
- tasks and on resource limited systems.</para>
|
|
|
+ tasks and on resource limited systems.</para-->
|
|
|
+ <para>该守护进程没有被设计为替代现有的 NTP 守护进程,
|
|
|
+ 而是一个仅仅实现了 SNTP 协议的客户端,可以被用于一些不太复杂的任务,
|
|
|
+ 或是资源紧张的系统。</para>
|
|
|
|
|
|
- <para>Starting with systemd version 216, the
|
|
|
+ <!--para>Starting with systemd version 216, the
|
|
|
<command>systemd-timesyncd</command> daemon is enabled by
|
|
|
default. If you want to disable it, issue the following
|
|
|
- command:</para>
|
|
|
+ command:</para-->
|
|
|
+ <para>从 systemd 版本 216 开始,<command>systemd-timesyncd</command>
|
|
|
+ 守护进程被默认启用。如果希望禁用它,执行以下命令:</para>
|
|
|
|
|
|
<screen role="nodump"><userinput>systemctl disable systemd-timesyncd</userinput></screen>
|
|
|
|
|
|
- <para>The <filename>/etc/systemd/timesyncd.conf</filename> file
|
|
|
- can be used to change the NTP servers that
|
|
|
- <command>systemd-timesyncd</command> synchronizes with.</para>
|
|
|
+ <para><filename>/etc/systemd/timesyncd.conf</filename> 文件
|
|
|
+ 可以被用于修改 <command>systemd-timesyncd</command>
|
|
|
+ 同步的服务器。</para>
|
|
|
+
|
|
|
+ <note><title>译注</title>
|
|
|
+ <para><ulink url="http://www.ntp.org.cn/pool.php"/>
|
|
|
+ 提供了 NTP 服务器的域名和 IP 地址列表。</para>
|
|
|
+ </note>
|
|
|
|
|
|
- <para>Please note that when system clock is set to Local Time,
|
|
|
+ <!--para>Please note that when system clock is set to Local Time,
|
|
|
<command>systemd-timesyncd</command> won't update hardware
|
|
|
- clock.</para>
|
|
|
+ clock.</para-->
|
|
|
+ <para>注意,当系统时钟设定为本地时间时,
|
|
|
+ <command>systemd-timesyncd</command> 不会更新硬件时钟。</para>
|
|
|
|
|
|
</sect2>
|
|
|
|