Merge pull request #1964 from su-kaiyao/master

su-kaiyao translated 20141106 timedatectl--Control Linux System Time and Date in Systemd.md
This commit is contained in:
Xingyu.Wang 2014-11-09 16:41:31 +08:00
commit 2414cbe9a1
2 changed files with 72 additions and 73 deletions

View File

@ -1,73 +0,0 @@
[su-kaiyao] translating
timedatectl - Control Linux System Time and Date in Systemd
================================================================================
**timedatectl** is a Linux utility that may be used to query and change the system clock and it's settings. It is distributed as part of the [systemd system and service manager][1] and allows you to review and change the configuration of the system clock.
In this article we will cover all aspects of using this small but important utility
### Current status of the time on the system ###
To have a look at the current date/time on the system, as well as the current time settings on the system you can use the command without any arguments like this:
# timedatectl
And the output should look something like this:
![](http://blog.linoxide.com/wp-content/uploads/2014/10/timedatectl.jpg)
### Changing the date ###
To change the system date you simply have to type timedatectl set-time followed by the date in the format YYYY-MM-DD where YYYY stands for the year, MM for the month in 2 digit and DD for the day in 2 digit. For example if you wish to change the date to 4th of February 2015 you should use the following command:
# timedatectl 2015-02-04
### Changing the time ###
To change the time you will use the tool in a similar fashion, you will still use timedatectl set-time but use the format HH:MM:SS where HH stands for hour in 24-hour format, MM for minutes and SS for seconds. To set the current time to 22:04:43 use the following command:
# timedatectl 22:04:43
### Changing the timezone ###
Setting the correct timezone is crucial for time keeping specially if you synchronize it with the NTP protocol. First you you should list the available timezones in your region with the list-timezones option, you can also use grep and more to make the format easier to read like this:
# timedatectl list-timezones | grep America | more
This will display the list an easy to scroll format.
After you know how the timezone you wish to set is named you can change it with the following command:
# timedatectl set-timezone America/Los_Angeles
### Setup the local-rtc ###
The **real-time clock (RTC)**, commonly referred to as a hardware clock is completely independent of the current state of the operating system and runs even when the computer is shut down. You can configure the system to maintain the RTC in universal time or in local time. Note that maintaining the RTC in the local timezone is not fully supported and will create various problems with time zone changes and daylight saving adjustments. If at all possible, keep the RTC in UTC mode. The only issue with this may be that other operating systems may not fully support it (in case you run 2 operating systems on the same machine).
To have the RTC set to UTC use the following setting:
# timedatectl set-local-rtc 0
To have it set in local time, use this:
# timedatectl set-local-rtc 1
### Setup NTP synchronization ###
**Network Time Protocol (NTP)** is a networking protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks. NTP is intended to synchronize all participating computers to within [a few milliseconds of Coordinated Universal Time (UTC)][2]. If you wish to set NTP synchronization you can use the set-ntp option to have this setup. Use “no” to disable NTP synchronization and use “yes” to have it enabled.
# timedatectl set-ntp yes
--------------------------------------------------------------------------------
via: http://linoxide.com/linux-command/timedatectl-change-time-date-systemd/
作者:[Adrian Dinu][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://linoxide.com/author/adriand/
[1]:http://www.freedesktop.org/wiki/Software/systemd/
[2]:https://en.wikipedia.org/wiki/Coordinated_Universal_Time

View File

@ -0,0 +1,72 @@
timedatectl - 管理Linux系统的时间和日期
===
**timedatectl**是用来查询和修改系统时间和配置的Linux应用程序。它是[系统服务管理][1]的一部分,并且允许你检查和修改系统时钟的配置。
在这篇文章中,我们将涉及该小巧但十分重要应用程序的所有方面
### 系统当前的时间状态 ###
想要查看系统当前日期/时间,以及可使用不带任何参数的命令查看当前系统时间配置,可以这样:
# timedatectl
输入的结果就像这样:
![](http://blog.linoxide.com/wp-content/uploads/2014/10/timedatectl.jpg)
### 修改日期 ###
想要修改系统日期你可以简单地使用timedatectl设置时间命令紧随命令的是YYYY-MM-DD格式的日期YYYY代表年MM代表2位数字的月份DD代表2位数字的天。举个例子如果你想把日期改为2015年2月4号,你应该使用下面的命令:
# timedatectl 2015-02-04
### 修改时间 ###
想要修改时间你可以以相同的方式使用该工具但是使用的格式为HH:MM:SSHH代表24小时制的时钟MM代表分钟SS代表秒钟。想将当前时间设为22:04:43使用下面的命令
# timedatectl 22:04:43
### 修改时区 ###
设置正确的时区是保持时间同步的关键特别是在你使用NTP协议同步的时候。首先你应该使用list-timezones选项列出你所在区域的可用时区你也可以使用grep和more来让格式方便阅读
# timedatectl list-timezones | grep America | more
这将显示一个简单的滚动列表格式。
之后,你就会知道你想设置的时区是如何命名的,然后使用下面的命令修改它:
# timedatectl set-timezone America/Los_Angeles
### 设置本地时钟 ###
**实时时钟RTC**通常被称为硬件时钟完全独立于操作系统当前状态甚至可以在计算机关闭的时候工作。你可以配置系统使用国际时间或当地时间维持RTC。注意使用当地时区维持RTC并不完美支持而且还有可能因为时区变化和夏令时调整引起许多问题。如果有可能在UTC模式下保持RTC。这一做法的唯一问题是其他操作系统可能不完全支持它如果你在同一台机器上允许2个操作系统
使用UTC模式维持RTC使用下面的命令
# timedatectl set-local-rtc 0
使用当地时间维护,使用:
# timedatectl set-local-rtc 1
### 设置NTP同步 ###
**网络时间协议NTP**是在分组交换计算机系统间进行时钟同步的可变数据延迟的网络协议。NTP被设计使用[几毫秒的协调通用时间][2]来同步所有参与的计算机。如果你希望设置NTP同步你可以使用set-ntp选项设置。使用“no”关闭NTP同步使用“yes”开启。
# timedatectl set-ntp yes
---
via: http://linoxide.com/linux-command/timedatectl-change-time-date-systemd/
作者:[Adrian Dinu][a]
译者:[su-kaiyao](https://github.com/su-kaiyao)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://linoxide.com/author/adriand/
[1]:http://www.freedesktop.org/wiki/Software/systemd/
[2]:https://en.wikipedia.org/wiki/Coordinated_Universal_Time