hwclock-w将系统时间同步到BIOS.doc_第1页
hwclock-w将系统时间同步到BIOS.doc_第2页
hwclock-w将系统时间同步到BIOS.doc_第3页
hwclock-w将系统时间同步到BIOS.doc_第4页
hwclock-w将系统时间同步到BIOS.doc_第5页
免费预览已结束,剩余2页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、hwclock -w将系统时间同步到BIOS我使用过的Linux 命令之 hwclock -查询和设置硬件时钟本文链接: (转载请注明出处)用途说明hwclock 命令,与 clock 命令是同一个命令,主要用来查询和设置硬件时钟(query and set the hardware clock (RTC))。RTC=Real Time Clock,也就是硬件时钟。在Linux 中有硬件时钟与系统时钟等两种时钟。硬件时钟是指主机板上的时钟设备,也就是通常可在BIOS 画面设定的时钟。系统时钟则是指 kernel 中的时钟。所有Linux 相关指令与函数都是读取系统时钟的设定。因为存在两种不同的

2、时钟,那么它们之间就会存在差异。根据不同参数设置,hwclock 命令既可以将硬件时钟同步到系统时钟,也可以将系统时钟同步到硬件时钟。关于系统时钟与硬件时钟的关系的说法,网上分成了两种:第一种:当Linux 启动时,硬件时钟会去读取系统时钟的设置,然后系统时钟就会独立于硬件运作。第二种:当Linux 启动时,系统时钟会去读取硬件时钟的设定,之后系统时钟即独立运作。到底那一种才是正确的呢?执行一下man hwclock可以看到里面有一段:man hwclock写道The System Time is the time that matters. The Hardware Clock s basi

3、c purpose in a Linux system is to keep timewhen Linux is not running. You initialize the System Time to the time from the Hardware Clock when Linuxstarts up, and then never use the Hardware Clock again.Note that in DOS, for which ISA was designed, theHardware Clock is the only real time clock.这段文字说明

4、, 第二种说法是正确的,第一种说法是错误的。但网上大部分文章都是第一种说法,所以说,网络虽好,要注意甄别。man hwclock写道It is important that the System Time not have any discontinuities such as would happen if you used the date(1L)program to set it while the system is running. You can, however, do whatever you want to the Hardware Clockwhile the system

5、 is running, and the next time Linux starts up, it will do so with the adjusted time from theHardware Clock.如果使用 date 命令修改了系统时间, 并不会自动去修改硬件时钟,因此,当系统下次重启时,系统时钟还会从硬件时钟去取, date 设置的时间就无效了。这大概就是为什么需要hwclock 命令的原因吧。常用参数-r, -showclock and print result读取并打印硬件时钟(read hardware)-s, -hctosys将硬件时钟同步到系统时钟(set the

6、system time from the hardware clock)-w, -systohc将系统时钟同步到硬件时钟(set thehardware clock to the current system time)使用示例示例一 hwclock 命令与 clock 命令是一个东西 rootnew55 # type -a hwclockhwclock is /sbin/hwclockhwclock is /usr/sbin/hwclockrootnew55 # ls -l /sbin/hwclock /usr/sbin/hwclock -rwxr-xr-x 1 root root 3409

7、6 2010-01-07 /sbin/hwclocklrwxrwxrwx 1 root root18 08-13 00:14/usr/sbin/hwclock -> ././sbin/hwclock rootnew55 # type -a clockclock is /sbin/clockrootnew55 # ls -l /sbin/clocklrwxrwxrwx 1 root root 7 08-13 00:14 /sbin/clock -> hwclockrootnew55 #示例二显示硬件时钟 rootnew55 # hwclock2010年 11月 06 日 星期六21

8、时 09 分 28 秒-0.134840 secondsrootnew55 # hwclock -r2010年 11 月 06 日 星期六21时 09 分 33 秒 -0.469123 secondsrootnew55 # hwclock -show2010 年 11 月 06 日 星期六 21 时 09 分 45 秒 -0.127548 secondsrootnew55 #示例三修改日期并同步到硬件时钟rootnew55 # date2010年 11 月 06 日 星期六21:11:57 CSTrootnew55 # date 11062112<=格式mmddHHMM ,即月日时分20

9、10 年 11月 06 日 星期六 21:12:00 CSTrootnew55 # hwclock -wrootnew55 # hwclock2010 年 11 月 06 日 星期六 21 时 12 分 13 秒 -0.648818 secondsrootnew55 #注:要使系统时间准确,最好还是使用ntp 方式。示例四使用 ntpdate 命令从网络同步时间, 再同步到硬件时钟ntpdate 命令是使用NTP 协议来从网络同步时间的命令。NTP=Network Time Protocol网络时间协议。rootnew55 # ntpdate 0. 6 Nov21:17:55 ntpdate4829: step time server 8 offset -1.025258 secrootnew55 # date2010年 11 月 06 日 星期六21:17:59 CSTroo

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论