In this tutorial, we want to teach you How To Set Up Time Synchronization on Centos 7.
Time synchronization is the process of coordinating the time of independent clocks. Clocks and timepieces often utilize relatively low-cost components that are not particularly precise. Many will drift by several seconds each day.
Even clocks set to identical times will differ significantly after a relatively short period. In modern computing, clock drift can be a severe problem.
- The process of coordinating the clocks of computers is vitally important.
- Without synchronization, clocks will diverge.
- Modern distributed computer systems rely on clock coordination.
- GPS and GNSS systems are essential sources of accurate time.
- Protocols such as NTP and PTP synchronize networks of computers.
Network Time Protocol (NTP) was developed to coordinate the time of the Internet and networked computers. It is one of the oldest Internet protocols still in use today.
Steps To Set Up Time Synchronization on Centos 7
To set up time synchronization, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide the Initial Server Setup with Centos 7.
Now follow the steps below to complete this guide.
Check Time Zone And Clock on Centos 7
The most basic command to find out the time on your server is “date”. Any user can run the following command to check the date and time on Centos 7:
Output Sat Oct 1 04:35:48 EDT 2022
Note: Most often your server will default to the UTC time zone. UTC is Coordinated Universal Time, the time at zero degrees longitude. Also, using Universal Time reduces confusion when your infrastructure spans multiple time zones.
If you have requirements and need to change the time zone on Centos 7, you can use the “timedatectl” command.
First, list the available time zones on Centos 7 with the following command:
sudo timedatectl list-timezones
In your output, you will see a list of available time zones on Centos 7.
When you find the correct time zone, use the following command to set the time zone:
sudo timedatectl set-timezone America/New_York
Remember to replace the time zone you have found in the list.
Now that you know how to check the time zone and clock on Centos 7, let’s install and start NTP.
Install NTP and Check the ntpd staus on Centos 7
To install NTP on your server, you can use the following command:
sudo yum install ntp
Then, restart your service with the following command:
sudo systemctl restart ntpd
Verify that the service is active and running on your server:
sudo systemctl status ntpd
in your output you will see:
Output ● ntpd.service - Network Time Service Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled; vendor preset: disabled) Active: active (running) since Sat 2022-10-01 04:37:20 EDT; 7s ago Process: 8082 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS) Main PID: 8083 (ntpd) CGroup: /system.slice/ntpd.service └─8083 /usr/sbin/ntpd -u ntp:ntp -g
To get more information about the status of ntpd, you can use the following command:
Your output should similar to this:
Output remote refid st t when poll reach delay offset jitter ============================================================================== *birlic.alsys.ro 22.214.171.124 2 u 36 64 1 0.975 -3.599 0.077 +time.xindi.eu 126.96.36.199 2 u 35 64 1 2.879 -2.421 0.090 +birlic.v6.alsys 188.8.131.52 2 u 34 64 1 49.501 -3.603 0.109
Your output will be different.
If everything went well then Your date and time should be synchronized from the NTP Server on Centos 7. You can verify your timezone with the following command:
Output Local time: Sat 2022-10-01 04:45:39 EDT Universal time: Sat 2022-10-01 08:45:39 UTC RTC time: Sat 2022-10-01 08:45:38 Time zone: America/New_York (EDT, -0400) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: yes Last DST change: DST began at Sun 2022-03-13 01:59:59 EST Sun 2022-03-13 03:00:00 EDT Next DST change: DST ends (the clock jumps one hour backwards) at Sun 2022-11-06 01:59:59 EDT Sun 2022-11-06 01:00:00 EST
“NTP synchronized: yes” means that the time on Centos 7 has been successfully synced, and the “NTP enabled: yes” means that the timesyncd is enabled and running.
At this point, you learn to view the system time, change time zones, and work with ntpd on Centos 7.
Hope you enjoy it.
You may be like these guides:
Set up and Configure Apache Cassandra on Centos 7
How To Install OpenCV on Centos 7
How To Install TensorFlow on Centos 7