Sync Date on CentOS 6 VM servers

My VM on ESXi have all different dates. Here is how toset them the same.

date

First, you’ll need to install NTP. For Debian or Ubuntu, that would be this command:


# sudo apt-get install ntp

For Redhat or CentOS, you’ll need to use this one:


# yum install ntp

Then you’ll want to edit the /etc/ntp.conf file, which is quite possibly already filled out for you.


# nano /etc/ntp.conf

You can get a list of server addresses at www.pool.ntp.org. Here are the North America ones:


server 0.north-america.pool.ntp.org
server 1.north-america.pool.ntp.org
server 2.north-america.pool.ntp.org
server 3.north-america.pool.ntp.org

Set it to run at boot

# chkconfig --list
ntpd            0:off   1:off   2:off   3:off   4:off   5:off   6:off

For Redhat and CentOS 6

chkconfig ntpd on
# ntpd            0:off   1:off   2:on    3:on    4:on    5:on    6:off

For Redhat 7 and CentOS 7

# systemctl enable ntpd.service

CentOS 6 restart or start the NTPD service:


# /etc/init.d/ntpd restart

CentOS 7 Restart

# /bin/systemctl start  ntpd.service

If you want to update the time right now, you can stop the NTP service and then run the following command, swapping out your preferred server for pool.ntp.org.


/usr/sbin/ntpdate pool.ntp.org

Leave a Comment