linux 修改时区

38 篇文章 1 订阅


先查看当前系统时间

node@node5:~$ date -R
Fri, 22 Jul 2022 09:51:10 +0800

设置时区

tzselect

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

切换时区

node@node4:~$ sudo ln -f -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 

node@node4:~$ date -R
Fri, 22 Jul 2022 09:54:08 +0800

写入CMOS

sudo hwclock --systohc
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大怀特

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值