Principles of centos 6/7 off the pit and set the system time zone updates UTC

Today, it took a little time to get to know the set time on linux / time zone is how it was. Actually wait until after his roommate looked back system time ubuntu suddenly broke through the blind spot. And coincidence, ubuntu also use timedatectl, so let's read on.

 

In general, let the system date linux command output correct time CST, only two steps:

The first step, UTC time update:

  You can use the command ntpdate: ntpdate -u ntp.api.bz

  PS: ntp.api.bz is a NTP server, you can get the UTC time. aliyun seems to have an NTP server, then you can use the search about.

The second step, set your system time zone:

  centos 6 set time zone:

    Use tzselect on my centos 6.7, is a guided procedure, in front of the digital input corresponds to the character, the middle will probably run into Asia, China, Beijing Time and other options, you can select them in front of the words

  centos 7 set time zone:

    centos 7 conveniently has a new command set zone: timedatectl set-timezone Asia / Shanghai. Other optional alternate time zone as well as Asia / Chongqing (CST), Asia / Taipei (CST), Asia / Hong_Kong (HKT) and the like.

    If it is not set in China time zone, there is another command to view timedatectl list-timezones, and then select the time zone. View more Other commands through timedatectl -h.

 

Set time principle / time zone:

  First, understand what GMT and UTC, ummm recent wind tight, there is a reference to the answer to Baidu search: https://zhidao.baidu.com/question/153332934.html

  Understanding of GMT and UTC after, then you need to know the operating system will store two time elements, one is UTC, one timezone. UTC is a standard time, timezone to make sure you are regions which time zone belongs, with the UTC + timezone can determine the time in your area, the basic rule is UTC time + timezone time difference, the time difference is typically ± 0.5h / 1h. ..8h and so on. For example, Japan's time zone is located on China than we are as early as 1h (8:00 them we 9:00).

  Now we know linux principle set time / time zone of the. If you refer to the online operations of some show ( yes, I'm caught up, ruining the zone file when Shanghai ), modify the contents of / etc / localtime file, then the corresponding will affect the / usr / share / zoneinfo / time zone file in the Asia / directory, this time if you are using centos 7, then the remedy is very simple, with a time zone change timedatectl like to provide three time zones can replace it. If centos 6, can refer to the following command, the effect is the same:

  ln -sf /usr/share/zoneinfo/Asia/Taipei /etc/localtime

 

 

Other answers show online operation:

  Search has been modified to hwclock (hardware clock), in fact, very easy to use.

 

Guess you like

Origin www.cnblogs.com/christmad/p/11570152.html