二种方法,一是使用命令tzselect
二是直接复制相应文件替换/etc/localtime

示例

cp /usr/share/zoneinfo/America/Los_Angeles /etc/localtime

tzselect 

Please identify a location so that time zone rules can be set correctly.
Please select a continent, ocean, "coord", or "TZ".
1) Africa 7) Europe
2) Americas 8) Indian Ocean
3) Antarctica 9) Pacific Ocean
4) Asia 10) coord - I want to use geographical coordinates.
5) Atlantic Ocean 11) TZ - I want to specify the timezone using the Posix TZ format.
6) Australia
4
Please select a country whose clocks agree with yours.
1) Afghanistan 10) Cyprus 19) Japan 28) Macau 37) Qatar 46) Turkmenistan
2) Armenia 11) East Timor 20) Jordan 29) Malaysia 38) Russia 47) United Arab Emirates
3) Azerbaijan 12) Georgia 21) Kazakhstan 30) Mongolia 39) Saudi Arabia 48) Uzbekistan
4) Bahrain 13) Hong Kong 22) Korea (North) 31) Myanmar (Burma) 40) Singapore 49) Vietnam
5) Bangladesh 14) India 23) Korea (South) 32) Nepal 41) Sri Lanka 50) Yemen
6) Bhutan 15) Indonesia 24) Kuwait 33) Oman 42) Syria
7) Brunei 16) Iran 25) Kyrgyzstan 34) Pakistan 43) Taiwan
8) Cambodia 17) Iraq 26) Laos 35) Palestine 44) Tajikistan
9) China 18) Israel 27) Lebanon 36) Philippines 45) Thailand
9
Please select one of the following timezones.
1) Beijing Time
2) Xinjiang Time
1

The following information has been given:

China
Beijing Time

Therefore TZ='Asia/Shanghai' will be used.
Selected time is now: 2021年 09月 01日 星期三 09:44:35 CST.
Universal Time is now: 2021年 09月 01日 星期三 01:44:35 UTC.
Is the above information OK?
1) Yes
2) No
1

You can make this change permanent for yourself by appending the line

TZ='Asia/Shanghai'; export TZ

to the file '.profile' in your home directory; then log out and log in again.

Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Asia/Shanghai

对比一下/etc/localtime文件与/usr/share/zoneinfo/Asia下面文件异同。

md5sum /etc/localtime /usr/share/zoneinfo/Asia/Chongqing 

e50e09ceae59b878c8f8fc15c2e0209e /etc/localtime
e50e09ceae59b878c8f8fc15c2e0209e /usr/share/zoneinfo/Asia/Chongqing

二个文件是一样的,所以要设置为CST, 可以直接复制Chongqing到/etc/localtime

cp /usr/share/zoneinfo/Asia/Chongqing /etc/localtime

md5sum /usr/share/zoneinfo/PRC

e50e09ceae59b878c8f8fc15c2e0209e /usr/share/zoneinfo/PRC

PRC大家都知道表示共和国了。。

要设置为UTC时间,就复制/usr/share/zoneinfo/UTC替换/etc/localtime即可。

本文链接地址:https://const.net.cn/378.html

标签: none

添加新评论