Tuesday, April 28, 2009

How to sync all your servers to use the same date and time

1. edit the ntpdate file:

root@Knoppix:/etc# cat /etc/default/ntpdate
# The settings in this file are used by the program ntpdate-debian, but not
# by the upstream program ntpdate.

# Set to "yes" to take the server list from /etc/ntp.conf, from package ntp,
# so you only have to keep it in one place.
NTPDATE_USE_NTP_CONF=no

# List of NTP servers to use (Separate multiple servers with spaces.)
# Not used if NTPDATE_USE_NTP_CONF is yes.
#NTPSERVERS="0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org"

NTPSERVERS="swisstime.ee.ethz.ch"

# Additional options to pass to ntpdate
NTPOPTIONS=""



2. invoke a time synchronization

root@Knoppix:/etc# ntpdate-debian
28 Apr 20:33:50 ntpdate[15046]: adjust time server 129.132.2.21 offset 0.370255 sec
root@Knoppix:/etc#


3. set up a cron job to invoke the time synchronization:

root@Knoppix:/# crontab -e

# every night at 2 am, sync/update the time
0 2 * * * ntpdate-debian


4. Optionally, update your time zone, by creating a symbolic link for /etc/localtime to the timezone of your choice. Example:

root@Knoppix:/ # ln -sf /usr/share/zoneinfo/EST /etc/localtime
(this changes the timezone to EST)

root@Knoppix:/ # ln -sf /usr/share/zoneinfo/GMT /etc/localtime
(this changes the timezone to GMT)

No comments:

Post a Comment