您的位置:首页 > 运维架构 > Linux

Linux 学习命令之修改日期时间

2017-11-03 11:54 309 查看
Linux 学习命令之修改日期时间一、日期时间修改

1. 查看时间和日期
[root@qdy ~]# date
2017年 11月 03日 星期五 11:39:49 CST


[root@qdy ~]# clock
2017年11月03日 星期五 11时42分52秒 -1.563496 seconds

显示日历

[root@qdy ~]# cal
十一月 2017
日 一 二 三 四 五 六
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30

2.设置时间和日期
例如:将系统日期设定成2017年11月3日的命令
[root@qdy ~]# date -s 2017/11/03
2017年 11月 03日 星期五 00:00:00 CST

将系统时间设定成下午11:45:50的命令
[root@qdy ~]# date -s 11:45:50
2017年 11月 03日 星期五 11:45:50 CST

3. 设置完系统时间后,还需要同步到硬件时钟上,将当前时间和日期写入BIOS,避免重启后失效,
[root@qdy ~]# hwclock -w 保存至硬件时间


[root@qdy ~]# clock --systohc 系统时间同步硬件时间

[root@qdy ~]#hwclock --systohc 系统时间同步硬件时间

[root@qdy ~]#clock --hctosys 硬件时间同步系统时间
[root@qdy ~]#hwclock --hctosys硬件时间同步系统时间
补充说明
上面命令中,--hctosys表示Hardware Clock to SYStem clock。

hc--Hardware Clock
sys--SYStem clock
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息