- 查看系统当前的时间状态
$ timedatectl status
Local time: 六 2021-10-30 09:33:37 CST
Universal time: 六 2021-10-30 01:33:37 UTC
RTC time: 六 2021-10-30 01:33:37
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
systemd-timesyncd.service active: yes
RTC in local TZ: no
$
- 修改时区
timedatectl set-timezone "Asia/Shanghai"
- 同步网络时间
sudo apt-get install -y ntpdate
ntpdate cn.pool.ntp.org
- 修改时间
sudo date -s "2021-10-29 23:00:00"
- 将时间写入硬件
hwclock --systohc
注意:最后将时间写入硬件一定要有,要不然当系统断网重启开机后时间依然是不对的。