1. 先使用 data -s
暂时修改系统时间
例如:
data -s '2020-12-31 15:31:20'
2. 使用 hwclock -w
命令同步硬件时间
hwclock 命令简介
[root@MY-EVC3000S-V2 bin]# 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)
使用hwclock -w
(Set hardware clock from system time)即可设置硬件时间为系统时间。实现永久更改Linux时间的方法。
3. reboot 重启
重启后发现系统时间就是你之前设置的时间。