How to Obtain Accurate Server Time in CentOS

In this article, we will show you how to quickly get accurate server time in CentOS distribution. Normally, if you have installed CentOS with a desktop environment, the easiest way to configure your computer to synchronize its clock with a remote server via the GUI “Enable Network Time Protocol” feature.

However, some times the above feature fails to work as expected. In this article, we will show you a straightforward way to set a accurate server time via the command line.

Read Also: Setting Up “NTP (Network Time Protocol) Server” in RHEL/CentOS 7

Note: All commands in this article are run as root user, if you are administering the system as a normal user, employ the sudo command to gain root privileges.

We can do this using the ntp and ntpdate command line utility, which sets system date and time via NTP. If you do not have this package installed on your system, run the command below to install it:

# yum install ntp ntpdate

Once you have installed the packages, start and enable the ntpd service, and view its status as follows.

# systemctl start ntpd
# systemctl enable ntpd
# systemctl status ntpd
Start NTP Service

Start NTP Service

Then run the ntpdate command below to add the specified CentOS NTP servers. Here, the -u switch tells ntpdate to use an unprivileged port for outgoing packets and -s enables for logging output from the standard output (default) to the system syslog facility.

# ntpdate -u -s

Next, restart the ntpd daemon to synchronize CentOS NTP server date and time with your local date and time.

# systemctl restart ntpd

Now check using the timedatectl command if NTP synchronization is enabled and if it is actually synchronized.

# timedatectl

Lastly, using the hwclock utility, set the hardware clock to the current system time using the -w flag as follows.

# hwclock  -w 

For more information, see the ntpdate and hwclock man pages.

# man ntpdate
# man hwclock

You might also like to read these following related articles.

  1. How to Synchronize Time with NTP Server in Ubuntu
  2. How to Check Timezone in Linux
  3. 5 Useful Commands to Manage File Types and System Time in Linux
  4. How to Set Time, Timezone and Synchronize System Clock Using timedatectl Command

That’s it! You can ask any questions or share your thoughts via the comment section below.

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

4 Responses

  1. prabhat sharma says:

    client time is not syncing to server time

  2. borys says:

    In CentOS 7 default time sync daemon is chrony. Do not rewrite your article without double check!.

    • Aaron Kili says:


      Unfortunately, chrony it not preinstalled. You must install and configure it before using it just like ntp. Therefore you can choose which time sync daemon to use, which is more or less the same.

      Thanks for the useful information.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.