Назад | Перейти на главную страницу

Как сохранить обновление аппаратных часов, когда сервер синхронизирует время с 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 x.x.x.x

Вы можете попробовать следующее в корневом каталоге crontab:

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

который будет синхронизировать его ежедневно, сразу после полуночи; не забывай --utc Отметьте, если часы вашей материнской платы находятся в UTC. Если ваши аппаратные часы дрейфуют так быстро, что их нужно корректировать чаще, чем один раз в день, у вас могут быть большие проблемы!

Обычно RHEL и CentOS синхронизируют аппаратные часы с системным временем во время плавной перезагрузки и выключения из ntpdate сценарий инициализации уже.

Ничто не мешает вам делать это чуть чаще, звоня /sbin/hwclock --systohc из работы cron.