Linux的时间分为System Clock(系统时间)和Real Time Clock (硬件时间,简称RTC)。
系统时间:指当前Linux Kernel中的时间。
硬件时间:主板上有电池供电的时间。
- 查看时间命令:
date:查看系统时间; hwclock:查看硬件时间;
- 安装插件:
yum install ntpdate
- 网络时间同步命令:
ntpdate -u 210.72.145.44 # 210.72.145.44:中国国家授时中心的官方服务器。 ntpdate cn.pool.ntp.org #或者这条命令
- 将系统时间写入硬件时间
hwclock --systohc
- 强制系统时间写入CMOS中防止重启失效
hwclock -w 或 clock -w
- 说明:
注意:若不加上-u参数, 会出现以下提示:no server suitable for synchronization found