当服务器与NTP同步时,如何保持更新硬件时钟?

当服务器与NTP服务器同步时,是否有任何方法可以定期同步硬件时钟? 我正在使用Centos 6.7。 以下是我的ntp.conf文件内容

# File for including partners custom ntp configurations leapfile "/etc/ntp/leap-seconds.list" # Permit general access to this service. restrict default kod nomodify notrap nopeer noquery restrict -6 default kod nomodify notrap nopeer noquery # Permit all access over the loopback interface. This could # be tightened as well, but to do so would effect some of # the administrative functions. restrict 127.0.0.1 restrict -6 ::1 # Replacement for the Undisciplined Local Clock. Allows a # group of ntpds to autonomously select a leader in the # event that all real time sources become unreachable. tos orphan 10 # NTP Drift file. # Put this in a directory to which the daemon can write. # No symbolic links allowed, either, since daemon renames. driftfile /var/lib/ntp/drift # Key file containing the keys and key identifiers used # when operating with symmetric key cryptography. keys /etc/ntp/keys # Specify the key identifiers which are trusted. #trustedkey 4 8 42 # Specify the key identifier to use with the ntpdc utility. #requestkey 8 # Specify the key identifier to use with the ntpq utility. #controlkey 8 server 127.127.1.0 # local clock server xxxx 

你可以在root的crontab试试以下内容:

 1 0 * * * /usr/sbin/hwclock --systohc 

它将在每天午夜之后同步; 如果你的主板时钟是UTC,不要忘记--utc标志。 如果您的硬件时钟漂移太快,需要每天更换一次以上,则可能会遇到更大的问题!

通常,RHEL和CentOS已经在系统时间内从硬件时钟同步重启,并且已经从ntpdate init脚本closures。

通过调用/sbin/hwclock --systohc从一个cron作业,没有什么能够阻止你更频繁地/sbin/hwclock --systohc