Nowadays, most people assume that all modern computers and operating systems have network time synchronization set up properly and switched on by default. However, this is not the case with many Linux servers—especially if you didn't install Linux and configure it yourself (as would be the case with most cloud-based OS images like those used to generate new servers on Linode).
After setting up a new server on Linode or some other Linux VPS or dedicated server provider, you should always do the following to make sure the server's timezone and date and time synchronization are configured and working correctly:
- Set the server's timezone correctly. Basically, create a symbolic link from
/etc/localtimeto the proper timezone file inside
- Make sure ntp is installed using your system's package manager (for example, on CentOS/RHEL:
$ sudo yum install ntpto install it if it's not installed already).
- Make sure ntpd is set to run on startup:
$ sudo /sbin/chkconfig ntpd on
- (Optional: Choose different/region-specific NTP servers and place them inside
/etc/ntp.conf, replacing the default servers that are in there).
- Make sure your iptables firewall is set to accept UDP traffic on port 123:
$ sudo iptables -I INPUT -p udp --dport 123 -j ACCEPT<br />
$ sudo iptables -I OUTPUT -p udp --sport 123 -j ACCEPT<br />
- Test ntp with ntpdate:
$ sudo ntpdate pool.ntp.org. This should show that there was an offset from the current system clock and the value retrieved over the Internet.
- Start ntpd, and your server should be happily in-sync, hopefully within a second or less at all times, with clocks around the world!
$ sudo service ntpd start
These instructions were tested on CentOS 5.x and 6.x. Other distributions should be similar.