Quick Table of Contents
How to keep the time accurate with ntp on Linux
1. Time will drift by itself
We noticed that our linux machine's time was drifting by rather alarming results. After being up for 84 days, the time was off by 14 minutes!
This is due to to linux keeping track of time separately from the hardware clock
bash-2.05a# uptime && /sbin/hwclock && date
1:54pm up 84 days, 14:53, 8 users, load average: 2.60, 1.95, 1.56
Wed Apr 21 13:40:04 2004 -1.644576 seconds
Wed Apr 21 13:54:47 EST 2004
2. Install ntp
Use your package manager to install ntp. Network time protocol daemon will keep the time accurate.
3. Edit configuration
Edit /etc/ntp.conf, and add some ntp servers you can call on. Our server is situated in Europe so we'll use
server 0.europe.pool.ntp.org
server 1.europe.pool.ntp.org
server 2.europe.pool.ntp.org
server 3.europe.pool.ntp.org
##
## Undisciplined Local Clock. This is a fake driver intended for backup
## and when no outside source of synchronized time is available.
##
server 127.127.1.0 # local clock (LCL)
fudge 127.127.1.0 stratum 10 # LCL is unsynchronized
I've added the 4 europe.pool.ntp.org lines to the default config.
ntp.org provides a list of servers you can use.
4. Start the ntp daemon
Start the ntp daemon and it should fix up the time.

