【Linux】Centos查看和修改系统时间和硬件时间
Centos系统时间和硬件时间Linux系统时钟和硬件时钟Linux时钟分为系统时钟(System Clock)和硬件时钟(Real Time Clock,简称RTC)。系统时钟:指当前Linux Kernel中的时钟;硬件时钟:指主板上由电池供电的时钟,这个硬件时钟可以在BIOS中进行设置;系统时间,是用CPU tick来维持的;硬件时间,是靠BIOS电池来维持。Linux时间方式在window
·
Centos系统时间和硬件时间
Linux系统时钟和硬件时钟
- Linux时钟分为系统时钟(System Clock)和硬件时钟(Real Time Clock,简称RTC)。
- 系统时钟:指当前Linux Kernel中的时钟;
- 硬件时钟:指主板上由电池供电的时钟,这个硬件时钟可以在BIOS中进行设置;
- 系统时间,是用CPU tick来维持的;
- 硬件时间,是靠BIOS电池来维持。
Linux时间方式
- 在windows中,系统时间会自动保存在BIOS的时钟里面,启动计算机时,系统会自动在BIOS中读取硬件时间,以保证时间的不间断;
- Linux下,默认情况下,系统时间和硬件时间以异步的方式运行,互补干涉;
- Linux系统在系统开机时,会自动从BIOS中取得硬件时间并设置为系统时间,之后系统时间和硬件时间以异步方式运行,互补干扰。
Linux硬件时间
硬件时间命令参数
-r, --show 读取并打印硬件时钟(read hardware clock and print)
-s, --hctosys 将硬件时钟同步到系统时钟(set the system time from the hardware clock)
-w, --systohc 将系统时钟同步到硬件时钟(set the hardware clock to the current system time)
--set --date="06/28/20 11:19:00" 修改硬件时钟,月/日/年 时:分:秒
命令示例
1、查看硬件时钟
[root@localhost ~]# hwclock -r
Sun 28 Jun 2020 06:02:23 PM CST -0.630830 seconds
[root@localhost ~]# hwclock
Sun 28 Jun 2020 06:02:26 PM CST -0.959155 seconds
[root@localhost ~]# hwclock --show
Sun 28 Jun 2020 06:02:33 PM CST -0.411513 seconds
2、同步系统时间到硬件时间(系统时间不变,修改硬件时间)
[root@localhost ~]# date
Fri Aug 7 10:35:11 CST 2020
[root@localhost ~]# hwclock --set --date="07/07/19 5:20:30"
[root@localhost ~]# hwclock
Sun 07 Jul 2019 05:20:34 AM CST -0.786518 seconds
############################################################
[root@localhost ~]# hwclock -w 【同命令hwclock --systohw】
[root@localhost ~]# hwclock
Fri 07 Aug 2020 10:39:18 AM CST -0.380548 seconds
3、同步硬件时间到系统时间(硬件时间不变,修改系统时间)
[root@localhost ~]# date
Sat Jun 6 19:20:31 CST 2020
[root@localhost ~]# hwclock
Sun 07 Jul 2019 05:22:29 AM CST -0.505952 seconds
[root@localhost ~]# hwclock -s
[root@localhost ~]# date
Sun Jul 7 05:24:14 CST 2019
4、修改硬件时间
[root@localhost ~]# hwclock --set --date="12/12/19 19:20:20" ---"月/日/年 时/分/秒"
[root@localhost ~]# hwclock
Thu 12 Dec 2019 07:20:25 PM CST -0.474765 seconds
5、修改系统时间
[root@localhost ~]# date
Sun Jul 7 08:18:58 CST 2019
[root@localhost ~]# date --set "10/10/10 12:12:12 " "月/日/年 时/分/秒"
Sun Oct 10 12:12:12 CST 2010
更多推荐
已为社区贡献1条内容
所有评论(0)