本地时间正确,但是时区不对:
root@mirror:/home/mirror# tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent, ocean, “coord”, or “TZ”.
- Africa
- Americas
- Antarctica
- Asia
- Atlantic Ocean
- Australia
- Europe
- Indian Ocean
- Pacific Ocean
- coord - I want to use geographical coordinates.
- TZ - I want to specify the time zone using the Posix TZ format.
#? 4
Please select a country whose clocks agree with yours. - Afghanistan 18) Israel 35) Palestine
- Armenia 19) Japan 36) Philippines
- Azerbaijan 20) Jordan 37) Qatar
- Bahrain 21) Kazakhstan 38) Russia
- Bangladesh 22) Korea (North) 39) Saudi Arabia
- Bhutan 23) Korea (South) 40) Singapore
- Brunei 24) Kuwait 41) Sri Lanka
- Cambodia 25) Kyrgyzstan 42) Syria
- China 26) Laos 43) Taiwan
- Cyprus 27) Lebanon 44) Tajikistan
- East Timor 28) Macau 45) Thailand
- Georgia 29) Malaysia 46) Turkmenistan
- Hong Kong 30) Mongolia 47) United Arab Emirates
- India 31) Myanmar (Burma) 48) Uzbekistan
- Indonesia 32) Nepal 49) Vietnam
- Iran 33) Oman 50) Yemen
- Iraq 34) Pakistan
#? 9
Please select one of the following time zone regions. - Beijing Time
- Xinjiang Time
#? 1
The following information has been given:
China
Beijing Time
Therefore TZ=‘Asia/Shanghai’ will be used.
Selected time is now: Fri Dec 31 13:40:43 CST 2021.
Universal Time is now: Fri Dec 31 05:40:43 UTC 2021.
Is the above information OK?
- Yes
- 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
root@mirror:/home/mirror:~$ date
Fri Dec 31 05:39:06 UTC 2021
修改完成后,发现时区还是不正确。按网上的方法cp:
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
root@mirror:/home/mirror# date -R
Fri, 31 Dec 2021 14:01:03 +0800
vi /etc/localtime
发现最大的变化是时区变了
CST0 ---->CST-8
下次直接vi /etc/localtime 修改时区试试。
以上是时间正确,时区不对的处理方法。
如果是本地时间本身就不正确,方法如下:
date -s MM/DD/YY //修改日期
date -s hh:mm:ss //修改时间
在修改时间以后,还要修改硬件CMOS的时间,方法如下:
hwclock --systohc //非常重要,如果没有这一步的话,后面时间还是不准