1,修改Linux时间:date -s '2022-09-12 22:00:00'
这种方式只是临时修改系统时间,当系统重新启动的时候就会还原。
2,hwclock --set --date '2022-09-12 22:00:00'
这是修改硬件的时间 也就是永久性修改Linux的时间
[root@localhost ~]# hwclock --help
BusyBox v1.23.1 (2016-02-23 09:52:57 CST) multi-call binary.
Usage: hwclock [-r|--show] [-s|--hctosys] [-w|--systohc] [-t|--systz] [-l|--localtime] [-u|--utc] [-f|--rtc FILE]
Query and set hardware clock (RTC)
-r Show hardware clock time
-s Set system time from hardware clock
-w Set hardware clock from system time
-t Set in-kernel timezone, correct system time
if hardware clock is in local time
-u Assume hardware clock is kept in UTC
-l Assume hardware clock is kept in local time
-f FILE Use specified device (e.g. /dev/rtc2)
步骤:
1.date 查看系统时间
2.hwclock --show 查看硬件的时间 hwclock -r
3.hwclock --set --date '2022-09-12 22:00:00'' 设置硬件时间为22年9月12日22点00分00秒
4.hwclock --hctosys 设置系统时间和硬件时间同步