Jan 16, 2014

Synchronize time using NTP on CentOS

If we run CentOS on a virtual machine, there will be time that the server time is off a few seconds or even minutes. We can install and use ntp to update server time:

yum -y install ntp
chkconfig --level 235 ntpd
service ntpd start
date

If we want to manually sync server time with a time server, then we need to stop ntpd service first, then use ntpdate to sync time:

service ntpd stop
ntpdate 0.centos.pool.ntp.org
ntpdate 0.pool.ntp.org
date