When using a CentOS 7 server in a production environment, it is ideal and necessary to configure certain parameters in the correct way so that all the associated processes work in the proper way..
One of these parameters is the server time since a bad synchronization and configuration of this will incur a malfunction of applications that depend on time resource factors and this always affects synchronization tasks , such as updates and files, if the server time and client computers is incorrect.
Today in TechnoWikis we will see how in a few steps we will adjust the time of our CentOS 7 server..
To keep up, remember to subscribe to our YouTube channel! SUBSCRIBE
1. Install NTP to set server time on CentOS Linux
Step 1
To correctly adjust the time in CentOS 7, we will use the ntp and ntpdate commands and for its installation we will execute the following command:
yum install ntp ntpdate
Step 2
Once the packages are loaded we will see the following. There we enter the letter and to confirm the download and installation of ntp and ntpdate.
2. Configure NTP to set server time in CentOS Linux
Step 1
Once installed, we will execute the following commands:
systemctl start ntpd (Start the ntp service) systemctl enable ntpd (Enable ntp service) systemctl status ntpd (Displays the status of the ntp service)
Step 2
With this validated, we will execute the ntpdate command in order to add the defined NTP CentOS servers. In this case, the -u switch tells ntpdate to use an unprivileged port for outgoing packets and the -s parameter enables output logging from a standard output (by default) to the system syslog function, we execute the following :
ntpdate -u -s 0.centos.pool.ntp.org 1.centos.pool.ntp.org 2.centos.pool.ntp.org
Step 3
Now, we restart the ntp service to synchronize the date and time of the NTP CentOS server with our local date and time:
systemctl restart ntpd
Step 4
We proceed to verify using the "timedatectl" command that NTP synchronization is enabled and if it is correct:
Step 5
There, we have used the "hwclock" utility, which configures the hardware clock with the current system time using the "-w" indicator like this:
hwclock -w
Step 6
If you need help with the "ntp" command, we can execute one of the following options:
man ntpdate man hwclock
We can see how easy it is to adjust the CentOS 7 time and thus allow all the associated services and processes to not be affected.