Many times you may notice a time drift problem on the server. It is common with some of the AMD server series as well.  In most cases its impact is not very high and it can be controlled by setting up a cron to run each minute to make sure the time remains close to accurate.

e.g. you can setup below cron in either root cron file at /var/spool/cron or in /etc/crontb


*/1 * * * * rdate -s rdate.cpanel.net

This basically syncs the time using rdate, you can use Cpanel’s rdate server or any of other public rdate servers.

Another way to fix it is by setting up ntpd (Network Time Protocol Daemon) on the server and is a method to achieve more accurate results.

You can install ntp using following simple commands :

yum install ntp
#edit /etc/ntp.conf for choice of your server
vi /etc/ntp.conf
#The default timer servers should work too , or you can update them as per your liking.

The service can be controlled using below simple/standard commands :

service ntpd start
service ntpd stop
service ntpd restart

There are more detail configuration settings as well like drift etc, but for normal use the default settings should be fine. I will cover the details for ntp installation and configuration in some other post.

Another reason for time drift ( usually a crazy one ) can be kernel specific problem. That is in this case the time drifts forward and background with a jump of 20 / 30 seconds, and this becomes a serious problem resulting in failure of different services, one server I handled had both imap and ftp services failing on it.
This was a Cpanel server with courier throwing below error :

“BYE Clock skew detected. Check the clock on the file server”

And ftp was also failing with such a time drift as was not able to do the initial connection session.

This was resolved by installing the latest CentOS5 kernel on the related sever.

So for resolving a time drift issue, your sequence would be from rdate cron, ntpd to kernel upgrade , depending on what exactly is the problem and how severe it is.

If you have to choose between cron and ntpd then ntpd solution is preferred.

Tags: , , ,

3 Comments on How To : Fix the time drift issue on a linux server

  1. Matt says:

    Setting up a cron might be a good fix for the first few hours until you can reboot the machine to load the new kernel, otherwise the first sugestions are a kludge and should be avoided as anything more than very temporary.

    These “Time Drifts” are almost always on AMD 5000 series processors. Has anyone else seen any other machines with this problem? On the AMD 5000 series, a kernel update will fix them every time. If you are running ksplice it seems to have forgotten about the patches that fix this problem, so you are going to have to actually load the latest kernel and reboot.

  2. Riz Khan says:

    The issue is common for AMD 2800 to almost AMD 5000 series. If you are already running the latest kernel and problem is still there then ntpd is the preferred solution or to start with even. The basic cron solution would also work fine in many conditions , running it on many servers without any problem. It all depends on which exact hardware you are dealing with and what kind of drift you are facing and what kind of impact that drift has on the services you are running. But yes comparing cron vs ntpd , the ntpd solution should be preferred.

    I would prefer few minutes reboot on most servers compared to ksplice , except the few where even few minutes outage is critical.

  3. Jim A says:

    Also just had a weird instance of 1G NIC doing this, skew was up to 5 minutes/24 hours. Switching to 100mbp/s NIC fixed it… no idea why, maybe someone else has the same issue as me

Leave a Reply to Riz Khan Cancel reply