Home » Server Managment » Fixing time drift in the servers (syncing with time servers)

Fixing time drift in the servers (syncing with time servers)

Sometimes the clock in the system may shows some drift ( lagging or leading) in time.  We can fix this by adjusting the tick rate in the server.

1. Compare the system time with that of any timeserver. You can use any of  the following command for this.

rdate -p rdate.cpanel.net ;date

OR

rdate -p rdate.darkorb.net ;date

Here rdate prints the time in remote timeserver( rdate.cpanel.net or rdate.darkorb.net) and date will print the current system time.

2. To synchronize the time with remote server issue the following commands.

rdate -s rdate.cpanel.net ;date

OR

rdate -s rdate.darkorb.net ;date

3. Now set the hardware clock in the server. Execute the following command for this.

hwclock –systohc

4. Now execute the same command (step1) after one or two minutes and see the drift in time. Check whether it increases or decreases.

5. Find the current tick rate using the following command. By default this will be 10000. You can interpret this as  10000 ticks causes one second in the server.

tickadj
tick = 10000

6. If the the time drift increases positively you need to reduce the tick rate. You can adjust the tick rate using the following command.

tickadj 9995
tick = 9995

7. Continue the above steps until the issue resolved.

===============

Aliter

To fix the time drift issue, you can put a cronjob to sync the time with the time server.

Add the following entry in cronjob ( type crontab -e to edit cron jobs)

*/5 * * * * rdate -s rdate.cpanel.net;/sbin/hwclock -w >/dev/null 2>&1

OR

*/5 * * * * rdate -s rdate rdate.darkorb.net;/sbin/hwclock -w >/dev/null 2>&1

Originally posted 2016-03-06 01:50:41.

About admin

I have been working with Linux based systems since 2002. I hope the article published on this site will be useful to those new to server administration.