+5 votes
243 views
How to set server time and hardware in CentOS Linux

in Linux / Unix by (552k points)
reopened | 243 views

1 Answer

+3 votes
Best answer

1. Install NTP to set server time on CentOS Linux
2. Configure NTP to set server time in CentOS Linux

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 

image

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.

image


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) 

image

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 

image

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:

image

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 

image

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.


by (3.5m points)
edited

Related questions

+5 votes
1 answer
+3 votes
1 answer
asked Nov 16, 2019 in Linux / Unix by backtothefuture (552k points) | 651 views
+5 votes
1 answer
+5 votes
1 answer
asked Jun 23, 2019 in Linux / Unix by backtothefuture (552k points) | 183 views
+3 votes
1 answer
asked Apr 27, 2020 in Linux / Unix by backtothefuture (552k points) | 227 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users