linux硬件时钟与软件时钟同步
首页->学习资料->linux教程->linux引导流程 关键词: 发布时间:2014-10-26 15:04:11 浏览次数:2790

一般情况下,这两个时钟是同步的,但有时候也有可能不同,如果不同,可能会出现time error错误;

查看软/硬件时钟的命令分别为date/hwclock

[root@localhost hurong]# date
Sun Oct 26 07:45:38 PDT 2014
[root@localhost hurong]# hwclock
Sun 26 Oct 2014 07:45:46 AM PDT  -0.053817 seconds
注:hwclock需要在root用户权限下才能运行;


利用hwclock -help可以查看帮助信息

[root@localhost hurong]# hwclock -help
hwclock - query and set the hardware clock (RTC)

Usage: hwclock [function] [options...]

Functions:
  -h | --help         show this help
  -r | --show         read hardware clock and print result
       --set          set the rtc to the time given with --date
  -s | --hctosys      set the system time from the hardware clock
  -w | --systohc      set the hardware clock to the current system time
       --systz        set the system time based on the current timezone
       --adjust       adjust the rtc to account for systematic drift since
                      the clock was last set or adjusted
       --getepoch     print out the kernel's hardware clock epoch value
       --setepoch     set the kernel's hardware clock epoch value to the
                      value given with --epoch
  -v | --version      print out the version of hwclock to stdout

Options:
  -u | --utc          the hardware clock is kept in UTC
       --localtime    the hardware clock is kept in local time
  -f | --rtc=path     special /dev/... file to use instead of default
       --directisa    access the ISA bus directly instead of /dev/rtc
       --badyear      ignore rtc's year because the bios is broken
       --date         specifies the time to which to set the hardware clock
       --epoch=year   specifies the year which is the beginning of the
                      hardware clock's epoch value
       --noadjfile    do not access /etc/adjtime. Requires the use of
                      either --utc or --localtime
       --adjfile=path specifies the path to the adjust file (default is
                      /etc/adjtime)
       --test         do everything except actually updating the hardware
                      clock or anything else
  -D | --debug        debug mode

当软件时钟与硬件时间不一样的时候,可以用hwclock --hctosys来将软件时钟与硬件时钟同步

[root@localhost hurong]# hwclock --hctosys
[root@localhost hurong]# date
Sun Oct 26 07:53:24 PDT 2014
[root@localhost hurong]# hwclock
Sun 26 Oct 2014 07:53:29 AM PDT  -0.329460 seconds

如果硬件时钟本身不对,可以用hwclock --set来进行修改,修改正确后再用hwclock --hctosys来同步:格式如下:(将硬件时钟设置为1996年9月22日 16时45分05秒)

hwclock --set --date="9/22/96 16:45:05"


如果直接改变软件时钟,则使用date 时间戳.秒数 ,如:

date 1223434344.23

赞:(0)
踩:(0)
相关文章
linux启动过程
热门文章
win7中将文件拷贝到虚拟机linux下
phpexcel设置行高及列宽,背景颜色,
rabbitmq无法启动
intellij idea不显示git push按钮
php7中使用mongodb的aggregate进行
centos7.4 64位下swoole安装及配置
laravel页面静态化的方法
navicate连接mycat报1184错误
单点登录sso原理及php实现方式及de
devops-jenkins容器为pending状态
好评文章
phpexcel设置行高及列宽,背景颜色,
php7中使用mongodb的aggregate进行
intellij idea打开文件所在文件夹
windows下使用MongoDB Compass Com
win7中将文件拷贝到虚拟机linux下
laravel 中悲观锁 & 乐观锁的使用
单点登录sso原理及php实现方式及de
navicate连接mycat报1184错误
rabbitmq无法启动
laravel整合dingo/api方法步骤:jwt
标签
rabbitmq mysql备份 elasticsearch golang swoole
我的项目
【github】www.github.com/hurong241
【码云】gitee.com/hu_rong/projects
【docker hub】hub.docker.com/repositories/hurong241
【packagist】packagist.org/users/hurong241/packages
站点信息
建站时间:2011年
文章数:607篇
浏览数:916013
粤ICP备18028092号-1  微信:hurong241