本地时间正确,但是时区不对:
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”.
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?
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 //非常重要,如果没有这一步的话,后面时间还是不准