In Linux server running Red Hat Enterprise Linux (RHEL) or CentOS, the time of the server may become incorrect and differ from official real clock after some time due to clock drift, as not all clocks is counting time at the same rate. As the result, the time on the server becomes faster or slower from the actual time as time goes by.

The correct server time is critical for some services, such as two-factor authentication (2FA) or when interfacing and authenticating via OAuth with Twitter API.

The solution for the incorrect time issue is by making use of NTP (Network Time Protocol) daemon, a networking protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks.

In Red Hat, CentOS, Scientific Linux and other derivatives, run the following commands to install NTP daemon and set it to auto-run on boo-up to automatically sync the date and time.

Installing NTP Daemon

yum install ntp

Set NTPD to Run and Start on System Startup

chkconfig ntpd on

NTP Daemon

Ensure that NTPD Daemon is Started

service ntpd start
/etc/init.d/ntpd start

Manually Sync the Time Instantly

ntpdate pool.ntp.org
Note
pool.ntp.org is a publicly available NTP time server. You can always replace it with your preferred time server, such as time.nist.gov, time.windows.com, time.apple.com and etc.