Linux的时间分为两种,硬件时间和系统时间两种:html
1、查看与修改系统时间spa
查看系统时间:datehtm
# dateget
Fri Nov 26 15:20:18 CST 1999同步
用指定的格式显示系统时间: date '+%x ,%X 'it
02/18/19 ,17:53:01 PMio
设置系统时间class
设置时间为下午14点36分。date
# date -s 14:36:00硬件
设置时间为2019年02月18号。
# date -s 20190218
设置时间伟2019年2月18号12:00
# date -s "2019-02-18 12:00:00"
修改完后,记得执行hwclock -w(将系统时间同步到硬件时间,等同于clock -w,等同于hwclock --systohc)
ln -sf /usr/share/zoneinfor/Asia/Shanghai /etc/localtime #更改时区
补充:
一、hwclock经常使用参数:
-r, --show 读取并打印硬件时钟(read hardware clock and print result )
-s, --hctosys将硬件时钟同步到系统时钟(set the system time from the hardware clock )
-w, --systohc 将系统时钟同步到硬件时钟(set the hardware clock to the current system time )
二、hwclock命令与clock命令是一个东西