Inaccurate time can cause misaligned scheduled tasks, inconsistent log timestamps, and clock skew in distributed systems. Configure a time synchronization service to automatically keep the system time on your instances accurate.
How it works
-
Network Time Protocol (NTP): A protocol that synchronizes clocks between a client and a server to within milliseconds by calculating network latency.
-
Alibaba Cloud NTP server: A time synchronization service provided by Alibaba Cloud. It offers endpoints in a VPC internal network, which allows ECS instances to synchronize time with minimal network latency.
-
chrony/ntpd/W32time: Time synchronization services that use NTP to synchronize an instance's system time with an NTP server. On Linux systems,
chronyoffers better performance thanntpd. Windows systems use the built-inW32timeservice.
Check time accuracy
Configure time synchronization
Linux (chrony)
Alibaba Cloud public images include a default time synchronization configuration. ECS instances created from these images run chrony by default for time synchronization. However, some older public images run ntpd by default. You can run the ps -C chronyd,ntpd -o comm= command to check which service is running. If the command returns ntpd, it indicates that ntpd is running by default. In this case, refer to Linux (ntpd) to configure time synchronization.
A Linux system can run only one time synchronization daemon. You must choose between chronyd and ntpd. Before starting one service, stop and disable the other.
To configure time synchronization on multiple instances, you can use Cloud Assistant for batch execution.
1. Configure NTP servers
-
Edit the
chronyconfiguration file.Alibaba Cloud Linux/CentOS/RHEL
sudo vim /etc/chrony.confUbuntu/Debian
sudo vim /etc/chrony/chrony.conf -
Configure the Alibaba Cloud NTP servers.
Comment out all lines that start with
serverin the file by using#, and copy the following content to the configuration file.ImportantTo ensure high availability and improve accuracy, you must configure multiple NTP time sources. Using a single time source creates a single point of failure and is strongly discouraged.
# This configuration includes NTP server addresses, and the minimum and maximum polling intervals. server ntp.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp10.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp11.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp12.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp7.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp8.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst server ntp9.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst -
Save the configuration file and restart the
chronyservice.sudo systemctl restart chronyd.service
2. Verify time synchronization
After restarting, the service gradually and smoothly adjusts the time. You can run sudo chronyc tracking to verify the synchronization status.
sudo chronyc tracking
The System time field in the output precisely shows the slight offset between your system time and the NTP time. For example, 0.000036150 seconds fast of NTP time indicates that the system time is ahead of the NTP time.
If the time offset is large, such as several minutes or hours, and your application can tolerate a time jump, consider manually synchronizing the time.
Reference ID : 64643D58 (100.100.61.88)
Stratum : 2
Ref time (UTC) : Sat Sep 20 07:55:33 2025
System time : 0.000036150 seconds fast of NTP time
Last offset : +0.000031322 seconds
RMS offset : 0.000044841 seconds
Frequency : 43.592 ppm slow
Residual freq : +0.000 ppm
Skew : 0.005 ppm
Root delay : 0.000228760 seconds
Root dispersion : 0.010518964 seconds
Update interval : 1029.1 seconds
Leap status : Normal
Linux (ntpd)
Some older public images for ECS instances, such as CentOS 6, use the ntpd service by default. Because ntpd is no longer actively maintained, we recommend upgrading to chrony for better performance and security.
A Linux system can run only one time synchronization daemon. You must choose between chronyd and ntpd. Before starting one service, stop and disable the other.
To configure time synchronization on multiple instances, you can use Cloud Assistant for batch execution.
1. Configure NTP servers
-
Edit the
NTPconfiguration file.sudo vim /etc/ntp.conf -
Configure the Alibaba Cloud NTP servers.
Comment out all lines that start with
serverin the file by using#, and copy the following content to the configuration file.ImportantTo ensure high availability and improve accuracy, you must configure multiple NTP time sources. Using a single time source creates a single point of failure and is strongly discouraged.
# This configuration includes NTP server addresses, and the minimum and maximum polling intervals. server ntp10.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10 server ntp11.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10 server ntp12.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10 server ntp7.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10 server ntp8.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10 server ntp9.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
-
Save the configuration file and restart the
ntpdservice.Alibaba Cloud Linux/CentOS/RHEL
sudo service ntpd restartUbuntu/Debian
service ntp restart
2. Verify time synchronization
After restarting, the service gradually and smoothly adjusts the time. You can run sudo ntpq -p to verify the synchronization status. The offset field in the output indicates the difference between the local time and the server time. Key parameters include:
-
offset: The difference between the system time and the server time, in milliseconds. The closer theoffsetis to 0, the more accurate the system time. -
jitter: The variation in time delay. A smaller absolute value indicates higher time precision.
If the time offset is large, such as several minutes or hours, and your application can tolerate a time jump, consider manually synchronizing the time.
sudo ntpq -p remote refid st t when poll reach delay offset jitter
==============================================================================
LOCAL(0) .LOCL. 10 l 17 64 1 0.000 0.000 0.000
+100.100.3.1 10.137.55.181 2 u 8 16 1 30.426 -307.76 0.153
*100.100.3.2 10.137.55.181 2 u 5 16 1 26.845 -309.25 0.221
+100.100.3.3 10.137.55.181 2 u 4 16 1 28.819 -309.37 0.187
-100.100.5.1 203.107.X.XX 2 u 3 16 1 50.478 -310.70 0.164
-100.100.5.2 203.107.X.XX 2 u 2 16 1 47.235 -311.89 0.246
100.100.5.3 203.107.X.XX 2 u 1 16 1 53.661 -310.50 0.119
Windows
GUI
The Windows graphical user interface (GUI) supports configuring only a single NTP server. This creates a single point of failure if the server has network issues or becomes unavailable.
For high availability in production environments, we strongly recommend using the command-line interface (CLI) to configure multiple NTP servers.
-
In the notification area of the taskbar, click the date and time, and then click Date and time settings.

-
On the Settings page, click Related settings > Add clocks for different time zones.
-
In the Date and Time window, click the Internet Time tab, and then click Change settings....
-
In the Internet Time Settings dialog box, select Synchronize with an Internet time server, enter
ntp.cloud.aliyuncs.comin the Server field, click Update Now, and then click OK. -
Verify the time synchronization. A success message confirms that the clock is synchronized with the server. If synchronization fails, check whether a firewall or security software is blocking UDP port 123.

CLI
Unlike the GUI, the CLI allows you to configure multiple time sources for automatic failover.
To configure time synchronization on multiple instances, you can use Cloud Assistant for batch execution.
1. Configure NTP servers
We recommend replacing the default Windows NTP server with Alibaba Cloud NTP servers. The following steps use Windows Server 2022 as an example.
-
Press
Win + R, entercmd, and pressEnterto open the command-line interface (CLI). -
Set the NTP servers. For example, use
ntp.cloud.aliyuncs.com ntp7.cloud.aliyuncs.com ntp8.cloud.aliyuncs.com ntp11.cloud.aliyuncs.com.w32tm /config /manualpeerlist:"ntp.cloud.aliyuncs.com ntp7.cloud.aliyuncs.com ntp8.cloud.aliyuncs.com ntp11.cloud.aliyuncs.com" /syncfromflags:manual /reliable:YES /update -
Restart the time service.
net stop w32time net start w32time -
Synchronize the time with the NTP servers.
w32tm /resync
2. Verify time synchronization
Run the command w32tm /query /status. If the Source is Local CMOS Clock instead of one of your configured NTP servers, synchronization has failed.
w32tm /query /statusLeap Indicator: 0(no warning)
Stratum: 3 (secondary reference - syncd via (S)NTP)
Precision: -23 (119.209ns per tick)
Root Delay: 0.0020371s
Root Dispersion: 0.0191713s
Reference ID: 0x64640302 (source IP: 100.100.3.2)
Last Successful Sync Time: 2025/10/28 14:37:42
Source: ntp11.cloud.aliyuncs.com
Poll Interval: 10 (1024s)
FAQ
Time synchronization in containers
No.
Do not run chronyd or ntpd inside a container. By default, containers share the host's system time and do not require separate time synchronization. Running a time synchronization service inside a container creates clock resource contention with the host and can severely impact application stability.
Manually synchronize time
Manually synchronizing time can cause a time jump and is not recommended. However, if the system time is off by a large amount (for example, several minutes or hours), you can perform a manual synchronization if your application can tolerate the sudden change.
Linux (chrony)
-
Stop the
chronyservice.sudo systemctl stop chronyd.service -
Manually synchronize the time.
ImportantTo ensure high availability and improve accuracy, do not use a single NTP time source. Before you perform a manual synchronization, confirm that you have configured multiple Alibaba Cloud NTP servers.
sudo chronyd -q -
Start the
chronyservice.sudo systemctl start chronyd.service
Linux (ntpd)
Alibaba Cloud Linux/CentOS/RHEL
-
Stop the
ntpdservice.sudo service ntpd stop -
Manually synchronize the time.
ImportantThe
ntpdservice is no longer actively maintained, and using thentpdatecommand for manual synchronization creates a risk of a time jump. If you must use it, specify three or more time sources in the command to reduce this risk. For a list of available servers, see Alibaba Cloud NTP server domains.ImportantPeriodically running
ntpdatewith a script is not a valid replacement for an NTP daemon. An NTP daemon uses sophisticated algorithms to maximize time accuracy and reliability while minimizing resource usage.sudo ntpdate ntp.cloud.aliyuncs.com ntp7.cloud.aliyuncs.com ntp10.cloud.aliyuncs.com ntp11.cloud.aliyuncs.com ntp12.cloud.aliyuncs.com -
Start the
ntpdservice.sudo service ntpd start
Ubuntu/Debian
-
Stop the
ntpdservice.sudo service ntp stop -
Manually synchronize the time.
ImportantThe
ntpdservice is no longer actively maintained, and using thentpdatecommand for manual synchronization creates a risk of a time jump. If you must use it, specify three or more time sources in the command to reduce this risk. For a list of available servers, see Alibaba Cloud NTP server domains.sudo ntpdate ntp.cloud.aliyuncs.com ntp7.cloud.aliyuncs.com ntp10.cloud.aliyuncs.com ntp11.cloud.aliyuncs.com ntp12.cloud.aliyuncs.com -
Start the
ntpdservice.sudo service ntp start
Alibaba Cloud NTP server domains
The following table lists the Alibaba Cloud NTP server addresses for different networks. This service supports only IPv4.
-
For ECS instances, use the VPC internal network domains for lower latency.
-
For servers outside Alibaba Cloud, use the public network domains.
|
VPC internal network |
Public network |
|
ntp.cloud.aliyuncs.com ntp7.cloud.aliyuncs.com ntp8.cloud.aliyuncs.com ntp9.cloud.aliyuncs.com ntp10.cloud.aliyuncs.com ntp11.cloud.aliyuncs.com ntp12.cloud.aliyuncs.com |
ntp.aliyun.com ntp1.aliyun.com ntp2.aliyun.com ntp3.aliyun.com ntp4.aliyun.com ntp5.aliyun.com ntp6.aliyun.com ntp7.aliyun.com |
Service fee
Yes, the service is free of charge. Alibaba Cloud public images include a default time synchronization configuration, and ECS instances created from these images use either chrony or the ntpd service to synchronize time by default.
Upgrade from ntpd to chrony
Some older public images for ECS instances, such as CentOS 6, are configured to use the ntpd service. The ntpd project is no longer actively maintained. If your ECS instance uses the ntpd service and your applications do not depend on it, we recommend upgrading to chrony.
-
Uninstall the
ntpservice.Alibaba Cloud Linux/CentOS/RHEL
sudo yum remove ntpUbuntu/Debian
sudo apt remove ntp -
Install
chrony.If the download fails, see How to resolve yum installation failures for chrony on CentOS 6 (EOL)?
Alibaba Cloud Linux/CentOS/RHEL
sudo yum install chronyUbuntu/Debian
sudo apt update sudo apt install chrony -
Configure
chrony.Edit the configuration file.
Alibaba Cloud Linux/CentOS/RHEL
sudo vim /etc/chrony.confUbuntu/Debian
sudo vim /etc/chrony/chrony.confIn this file, you can add NTP servers and other settings. The following is a simple
chrony.confexample:# NTP server settings server ntp.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst # Specify the location of the drift file. driftfile /var/lib/chrony/drift # Allow chronyd to be queried from localhost. allow 127.0.0.1The following table describes the parameters in the configuration file.
Parameter
Description
server ntp.cloud.aliyuncs.comThe domain name of the NTP server.
chronyconnects to this server to synchronize time.minpoll 4Specifies the minimum polling interval in seconds, as a power of 2. For example,
minpoll 4sets the interval to 2⁴, or 16 seconds. This meanschronysends a synchronization request to the server at least every 16 seconds.maxpoll 10Specifies the maximum polling interval in seconds, as a power of 2. For example,
maxpoll 10sets the interval to 2¹⁰, or 1024 seconds.iburstThis option speeds up the initial time synchronization. When
chronystarts, it sends a burst of requests (typically eight) to quickly get an accurate time from the server. -
Start the
chronyservice.-
Start the
chronyservice and enable it to start on boot.# Start the chrony service. sudo service chronyd start # Set chrony to start automatically when the system boots. sudo chkconfig chronyd on -
Check the
chronystatus. Use thechronyctool to check the status and synchronization ofchrony.# Check the service status. sudo service chronyd status -
Verify the time synchronization. Run the command to check the primary server status and the offset between the local clock and the time server.
sudo chronyc tracking
-
Resolve yum installation failures for chrony on CentOS 6
-
Back up and remove the old
repoconfigurations.sudo mkdir -p /etc/yum.repos.d/backup && sudo mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/ -
Create a new repository file that points to the official CentOS Vault. Run the following command to create a new
CentOS-Vault.repofile.sudo tee /etc/yum.repos.d/CentOS-Vault.repo <<'EOF' [C6.10-base] name=CentOS-6.10 - Base baseurl=http://vault.centos.org/6.10/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=1 [C6.10-updates] name=CentOS-6.10 - Updates baseurl=http://vault.centos.org/6.10/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=1 [C6.10-extras] name=CentOS-6.10 - Extras baseurl=http://vault.centos.org/6.10/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 enabled=1 EOF -
Clean the yum cache and rebuild it.
sudo yum clean all && sudo yum makecache -
Install chrony.
sudo yum install chrony
Related topics
-
For more information about time-related concepts and operations in Linux, or to learn about changes to time configurations in Linux public images, see Linux time and time zones.
-
The Precision Time Protocol (PTP) time synchronization service uses hardware-level timestamps and dynamic path compensation to achieve sub-microsecond clock synchronization. This ensures timing consistency in distributed systems, which makes it ideal for scenarios that require high time precision, such as high-frequency financial trading.