Linux permanently changes the system time and changes the hardware time

1. Modify Linux time:

date -s 时间

This method only temporarily modifies the system time, and it will be restored when the system restarts.

2. This is the time to modify the hardware, which is also the time to permanently modify Linux.

hwclock --set --date '2017-08-16 17:17:00'

Order:

1.date 查看系统时间

2.hwclock --show 查看硬件的时间 hwclock -r

3.hwclock --set --date '2017-08-16 17:17:00' 设置硬件时间为17年8月16日17点17分00秒

4.hwclock --hctosys 设置系统时间和硬件时间同步

5.clock -w 保存时钟 hwclock -w

By default, the system seems to use American time instead of China time. You need to modify the system's time zone to change the system's current time.

Log in to the system as ROOT user

Copy the corresponding time zone file and replace the CentOS system time zone file; or create a link file

cp /usr/share/zoneinfo/ Main Time Zone / Main Time Zone/ Primary time zone/Secondary time zone /etc/localtime

Available in China:

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime -R

Then reboot the system. After the restart, use the date command to check whether the current time of the system has changed to the current time in China.

Guess you like

Origin blog.csdn.net/YJ000312/article/details/129832306