123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <?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">
- %general-entities;
- ]>
- <sect1 id="ch-scripts-clock" revision="systemd">
- <?dbhtml filename="clock.html"?>
- <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
- <command>systemd-timedated</command> system service, which configures
- 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>
- 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
- time, chances are it is set to UTC time. Verify this by adding or subtracting
- 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>如果您不确定您的硬件时钟是否设置为 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
- 0
- LOCAL</literal>
- EOF</userinput></screen>
- <para>如果 <filename>/etc/adjtime</filename> 在初次引导时不存在,
- <command>systemd-timedated</command> 会假设硬件时钟使用 UTC ,
- 并据此调整该文件。</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> 也能修改系统时间和时区。</para>
- <para>如果要修改系统时间,执行以下命令:</para>
- <screen role="nodump"><userinput>timedatectl set-time YYYY-MM-DD HH:MM:SS</userinput></screen>
- <para>硬件时钟也会同时被更新。</para>
- <para>要修改当前时区,执行以下命令:</para>
- <screen role="nodump"><userinput>timedatectl set-timezone TIMEZONE</userinput></screen>
- <para>您可以通过运行以下命令查看可用的时区列表:</para>
- <screen role="nodump"><userinput>timedatectl list-timezones</userinput></screen>
- <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>网络时钟同步</title>
- <!--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-->
- <para>从版本 213 开始,systemd 附带了一个名为
- <command>systemd-timesyncd</command> 的守护进程,
- 可以用于将系统时间与远程 NTP 服务器同步。</para>
- <!--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-->
- <para>该守护进程没有被设计为替代现有的 NTP 守护进程,
- 而是一个仅仅实现了 SNTP 协议的客户端,可以被用于一些不太复杂的任务,
- 或是资源紧张的系统。</para>
- <!--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-->
- <para>从 systemd 版本 216 开始,<command>systemd-timesyncd</command>
- 守护进程被默认启用。如果希望禁用它,执行以下命令:</para>
- <screen role="nodump"><userinput>systemctl disable systemd-timesyncd</userinput></screen>
- <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,
- <command>systemd-timesyncd</command> won't update hardware
- clock.</para-->
- <para>注意,当系统时钟设定为本地时间时,
- <command>systemd-timesyncd</command> 不会更新硬件时钟。</para>
- </sect2>
- </sect1>
|