Operations 8 min read

How to Sync Linux Server Time with NTP, ntpdate, and Chrony

This guide walks you through installing and configuring NTP, using ntpdate for one‑off synchronization, troubleshooting common ntpdate errors, and setting up Chrony as an alternative NTP client, including manual time adjustments and timezone configuration on Linux systems.

Liangxu Linux
Liangxu Linux
Liangxu Linux
How to Sync Linux Server Time with NTP, ntpdate, and Chrony

1. Sync Time Using the NTP Service

Install the ntp package and start the service:

# yum -y install ntp
# systemctl start ntpd
# systemctl enable ntpd

Verify the service status: # systemctl status ntpd Edit /etc/ntp.conf to use a public server (e.g., server ntp.aliyun.com iburst) and restart the service:

# vim /etc/ntp.conf
# systemctl restart ntpd

Check synchronization with:

# ntpq -p

2. One‑off Sync with ntpdate

Run the command to adjust the clock immediately: # ntpdate ntp.aliyun.com Confirm the current time:

# date

3. Fixing ntpdate Sync Failures

If you encounter the error "the NTP socket is in use", stop the running NTP daemon first: # service ntpd stop # or: systemctl stop ntpd Then retry the synchronization:

# ntpdate ntp1.aliyun.com

4. Using Chrony for Time Synchronization

Install Chrony and enable it:

# yum -y install chrony
# systemctl enable --now chronyd

Check its status: # systemctl status chronyd Modify /etc/chrony.conf to point to a preferred server (e.g., server ntp1.aliyun.com iburst) and restart:

# vim /etc/chrony.conf
# systemctl restart chronyd

Verify the source list:

# chronyc sources

5. Manual Time Adjustments

Set the system clock directly:

# date -s "2012-05-23 01:01:01"
# date

Alternative date format (MMDDhhmmYYYY.ss): # date 090621282021.28 Synchronize hardware clock to system clock: # hwclock -w Display the date in a custom format: # date "+%Y-%m-%d %H:%M:%S" Set the timezone to Shanghai:

# timedatectl list-timezones | grep Shanghai
# timedatectl set-timezone Asia/Shanghai
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxNTPtime synchronizationchrony
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.