Friday, 6 November 2020

How to update ntp server in CENTOS 7-8?

Managing System Time and NTP in Linux

Keeping your server’s time accurate is crucial — whether it’s for logging, cron jobs, or secure connections. Here’s a quick guide to checking and setting time on a Linux system, along with enabling NTP for automatic synchronization.


🔍 Check the Current Time

Check the hardware clock (BIOS/RTC):

hwclock

Check the system clock (software):

timedatectl

⏱ Enable NTP (Network Time Protocol)

To let your system automatically sync with time servers, enable NTP:

timedatectl set-ntp yes

🕒 Manually Set the Time

If you need to set the time manually (e.g., no NTP available):

timedatectl set-time HH:MM:SS

(Replace HH:MM:SS with your desired time.)


⚙️ Start and Enable NTP Daemon

For continuous synchronization with NTP servers, start and enable the ntpd service:

sudo systemctl start ntpd
sudo systemctl enable ntpd

🌍 Sync with a Specific NTP Server

You can manually sync your system clock to a specific NTP server and then update the hardware clock:

ntpdate -u clock.ncbs.res.in && hwclock -w

✅ That’s it! Now your Linux system should stay in sync with accurate time.


No comments:

Post a Comment