Translate

субота, 24 серпня 2013 р.

Синхронизация времени с внешними серверами времени в Debian.

aptitude -y install ntpdate

В /usr/local/sbin/внести скрипт sync-time:

#!/bin/bash
. /usr/local/sbin/func/random_sleep

server=pool.ntp.org

random_sleep 600 120

# Sync the time with external server
echo "Sync time with $server."
/usr/sbin/ntpdate -s $server || exit 1

# Adjusts clock drift
/sbin/hwclock --adjust

# Set the hardware clock to current system time
/sbin/hwclock --systohc


Для того, чтоб при загрузке синхронизация проходила, надо:
создать /etc/cron.d/sync-time

#
# Regular cron job for time synchronization
#
PATH=/usr/local/sbin
HOME=/
LOG=/smart/null

# Every 23 hours, e.g. 2:11, 13:11, etc
11 */23 * * * root test -x /usr/local/sbin/sync-time && sync-time > $LOG

Немає коментарів:

Дописати коментар