微信搜索:“二十同学” 公众号,欢迎关注一条不一样的成长之路
硬件时间
硬件时钟是存储在主板上CMOS里的时间即BIOS时间,关机后该时钟依然运行,主板的电池为它供电。对应于嵌入式设备有一个RTC模块。硬件时钟即RTC时钟。信息比较少没时区、夏令时的概念。
系统时间
系统时间是软件系统的时钟。软件启动时会去读取硬件时间,之后则独立运行。独立于硬件时间,拥有时区、夏令时等信息。系统时间又因为系统的不同使用了两种时间管理方法:
- localtime:本地时间,目前只有 Windows 在使用。Windows 认为硬件时间就是本地时间,所以会直接把主板中的时间拿来当做当前的时间。设置或同步时间后也会把“正确”的时间写入主板,即操作系统中显示的时间跟BIOS中显示的时间是一样的。
- UTC:是一种世界标准时间(伦敦当地时间),Linux、Mac等类 UNIX系统多数会使用,UTC 加减时区之后才是本地时间。而类UNIX系统认为硬件时间是 UTC 标准时间,即把硬件时间当作 UTC,操作系统中显示的时间是硬件时间经过换算得来的(加减时区),即操作系统中显示的时间跟BIOS中显示的时间不一样相差对应的时区,比如说北京时间是UTC+8,则系统中显示时间是硬件时间+8。
Linux系统下查看系统时间和硬件时间
1.具体命令使用如下:
查看当前系统时间
设置系统时间
查看当前硬件时间
[root@localhost conf]# hwclock --set --date='03/22/19 10:08'
[root@localhost conf]# hwclock --systohc
[root@localhost conf]# hwclock
Fri 22 Mar 2019 10:08:58 AM CST -0.786577 seconds
[root@localhost conf]# date
Fri Mar 22 10:08:23 CST 2019
2.关于hwclock[hardware clock]命令
-s, --hctosys
Set the System Time from the Hardware Clock.#以硬件时间为标准,设置系统时间
Also set the kernel’s timezone value to the local timezone as
indicated by the TZ environment variable and/or
/usr/share/zoneinfo, as tzset(3) would interpret them. The
obsolete tz_dsttime field of the kernel’s timezone value is
set to DST_NONE. (For details on what this field used to
mean, see settimeofday(2).)
This is a good option to use in one of the system startup
scripts.
-w, --systohc
Set the Hardware Clock to the current System Time.##以系统时间为标准,设置硬件时间


发布评论