System time/zh-cn

系统时间，由系统时钟支持，Article description::在 Unix 系统中用于跟踪时间. 它可以由板载硬件时钟或外部时间服务器设置.

软件时钟 vs 硬件时钟
The, provided by the kernel, is implemented as a simple count of the number of ticks that have transpired since the 1 January 1970 00:00:00 UTC. This is called Unix time.

The (also known as real-time clock or RTC) is typically a component on the mainboard. It runs independent of the state of the operating system all the time, also when the computer is shutdown.

UTC 时间 vs 本地时间
The time for hardware clock can be modified to represent two standards: localtime or UTC time. The localtime is the real time of the time zone including DST. Preferred is UTC time because the system time gets computed by adding the time zone difference and DST. So daylight saving changes get automatically applied and changing the time zone are possible without changing the hardware clock. Exceptions can be made when using a dual-boot system; this is when the other operating system does not support or is not configured for an UTC hardware clock (by default, Windows uses localtime).

时区
为了确保时间正确，请选择正确的时区以便系统知道它所在的位置.

OpenRC
See.

systemd
comes with the command to manage the time zone:

要检查当前区域：

列出可用区域：

更改时区，例如德国：

LC_TIME
This defines formatting of dates and times. For more details see The GNU C Library

系统时钟
Typically the system clock time is set up by the hardware clock on boot. Alternatively it is possible to manually set the system clock or use a network time server.

命令可用于管理系统时钟时间：

要检查当前的软件时钟时间：

设置系统时钟，例如 2016 年 5 月 6 日 12:34：

时间服务器
See the or  article for information concerning the use of time servers.

systemd
systemd 带有 命令来管理系统时钟时间：

要检查当前的软件时钟时间：

设置系统时钟：

硬件时钟
要启用硬件时钟，必须激活以下内核选项：

在运行时，检查当前硬件时钟时间：

将硬件时钟设置为当前系统时钟：

同步硬件时钟和系统时间
Typically the hardware clock is used to setup the system clock on boot. This can be done by the kernel itself or by a boot service (init script). Also on shutdown the kernel or a service can write the software clock to the hardware clock. This aids the system in having the correct time on boot.

内核方法
On a sufficiently modern kernel (3.9 or newer), Linux can be configured to handle setting the system time automatically. To do so, enable the Set system time from RTC on startup and resume ( CONFIG_RTC_HCTOSYS ) and Set the RTC time based on NTP synchronization ( CONFIG_RTC_SYSTOHC ) kernel options:

The Set the RTC time based on NTP synchronization kernel option is currently supported by,  and  since version 5.9p1.

To check if the hardware time is updated, install and run:

Bit 6 of the reported number should be unset (0). More information in man pages (search '11 minute mode').

OpenRC
When using OpenRC the init script can set the system clock on boot and sync system time to the hardware clock on shutdown. The service is enabled by default and should be disabled in favor of the above mentioned in-kernel method. The script should not be run when using the kernel's real time clock.

If however there is a need for using the OpenRC, set both clock_hctosys and clock_systohc to  in. By default the service is configured for UTC time standard. To change to localtime add.

Restart the service and have the hardware clock init script run on system boot:

systemd
can be used to set the system clock on boot. Use to manage the hardware clock:

要检查当前硬件时钟时间：

将硬件时钟设置为当前系统时钟（UTC 时间标准）：

将硬件时钟设置为当前系统时钟（本地时间标准）：

Windows 双启动
Systems that dual boot with another operating system, such as Windows, generally have a struggle over the hardware clock. To make Windows not adjust the hardware clock back to local time, add the following registry entry.

For 64-bit Windows, open then browse to. Create a new QWORD entry called RealTimeIsUniversal, then set its value to. Reboot the system. The clock should now be in UTC time. For 32-bit Windows, follow the 64-bit instructions except use DWORD instead of QWORD.

外部资源

 * https://lifehacker.com/5742148/fix-windows-clock-issues-when-dual-booting-with-os-x - Dual booting with MS Windows, set RealTimeIsUniversal. Also tested with.
 * http://tldp.org/HOWTO/Clock-2.html - The Clock Mini-HOWTO.