All Products
Search
Document Center

Elastic Compute Service:Manage time synchronization services

Last Updated:Sep 30, 2025

Time drift can cause inconsistent scheduled tasks, mismatched log timestamps, and clock skew in distributed systems. To prevent these issues, configure a time synchronization service to automatically synchronize the time of your Elastic Compute Server (ECS) instance..

How it works

image
  • Network Time Protocol (NTP): A protocol for synchronizing time between a client and a server to within milliseconds by calculating network latency.

  • Alibaba Cloud NTP Server: A network of servers that provide time synchronization services. When accessed from within a virtual private cloud (VPC), they enable ECS instances to synchronize their time with extremely low network latency.

  • chrony/ntpd/W32time: Time synchronization clients that use the NTP protocol to synchronize an Instance's system time with an NTP server. On Linux and Unix-like systems, chrony is recommended for its higher accuracy and faster synchronization. chrony offers better performance than ntpd. Windows systems use the built-in W32time service.

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 to synchronize their time.

Some older Public Images run ntpd by default. Use the ps -C chronyd,ntpd -o comm= command to check the running process. If the output is ntpd, follow the steps in the Linux (ntpd) section to configure time synchronization.

1. Check and configure NTP server addresses

  1. Edit the chrony configuration file.

    Alibaba Cloud Linux/CentOS/RHEL

    sudo vim /etc/chrony.conf

    Ubuntu/Debian

    sudo vim /etc/chrony/chrony.conf
  2. Configure Alibaba Cloud NTP servers.

    Comment out all existing server lines by prefixing them with a #. Then, add the following configuration to the file.

    Using multiple NTP servers provides redundancy and improves time accuracy by allowing the client to select the best server.
    # Configuration information, including NTP server addresses, minimum polling interval, and maximum polling interval. 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
  3. Save the configuration file, exit the editor, and restart chrony.

    sudo systemctl restart chronyd.service

2. Verify time synchronization

After restarting, the service gradually adjusts the system time. Run sudo chronyc tracking to verify the synchronization status.

sudo chronyc tracking

The System time field in the output shows the offset between your system's clock and the NTP server's time. For example, 0.000036150 seconds fast of NTP time indicates a small discrepancy.

If the time offset is large (for example, several minutes or hours) and your workload can tolerate an abrupt time change, 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)

By default, some older Public Images for Alibaba Cloud ECS Instances, such as CentOS 6, come configured with the ntpd service. Because the NTP service is no longer actively maintained, we recommend upgrading to Chrony for better performance and security.

1. Check and configure NTP server addresses

  1. Edit the NTP configuration file.

    sudo vim /etc/ntp.conf
  2. Configure Alibaba Cloud NTP servers.

    Comment out all existing server lines by prefixing them with a #. Then, add the following configuration to the file.

    Using multiple NTP servers provides redundancy and improves time accuracy by allowing the client to select the best server.
    # Configuration information, including NTP server addresses, minimum polling interval, and maximum polling interval. 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
  3. Save the configuration file, exit the editor, and restart ntpd.

    Alibaba Cloud Linux/CentOS/RHEL

    sudo service ntpd restart

    Ubuntu/Debian

    service ntp restart

2. Verify time synchronization

After restarting, the service gradually adjusts the time. You can run sudo ntpq -p to verify the status. The offset field in the output indicates the time difference between the local clock and the server. Key parameters include:

  • offset: The time offset between the system clock and the server, in milliseconds. A value closer to 0 indicates higher accuracy.

  • jitter: The variation in time delay. A smaller value indicates more precise time synchronization.

If the time offset is large (for example, several minutes or hours) and your workload can tolerate an abrupt time change, 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.7.88 2 u 3 16 1 50.478 -310.70 0.164 -100.100.5.2 203.107.7.88 2 u 2 16 1 47.235 -311.89 0.246 100.100.5.3 203.107.7.88 2 u 1 16 1 53.661 -310.50 0.119

Windows

Graphical user interface (GUI)

Change the default NTP server in Windows Server (time.windows.com) to an Alibaba Cloud NTP server. The following steps use Windows Server 2022 as an example.

  1. In the notification area of the taskbar, click the date and time, and then click Date and time settings.

    image

  2. On the Settings page, click Related settings > Add clocks for different time zones.

  3. In the Date and Time dialog box, click Internet Time > Change settings...

  4. In the Internet Time Settings dialog box, select Synchronize with an Internet time server, enter ntp.cloud.aliyuncs.com, click Update now, and then click OK.

  5. Verify the synchronization. A success message confirms that the time has been updated. If the synchronization fails, check if a firewall or security software is blocking UDP port 123.

    image

Command-line interface (CLI)

1. Configure NTP servers

Change the default NTP server in Windows Server (time.windows.com) to an Alibaba Cloud NTP server. The following steps use Windows Server 2022 as an example.

  1. Press Win + R, enter cmd, and then press Enter to open the command prompt.

  2. Set the NTP server. The following example uses ntp11.cloud.aliyuncs.com.

     w32tm /config /manualpeerlist:"ntp11.cloud.aliyuncs.com" /syncfromflags:manual /reliable:YES /update
  3. Restart the time service.

     net stop w32time net start w32time
  4. Synchronize time with the NTP server.

    w32tm /resync

2. Verify time synchronization

Run the w3tm /query /status command. If the Source is Local CMOS Clock instead of the configured NTP server address, the synchronization has failed.

 w32tm /query /status

image

FAQ

How can I manually force a time synchronization?

To avoid the risks associated with sudden time jumps, we do not recommend manual synchronization. However, if the time offset is significant (for example, several minutes or hours) and your workload can tolerate a sudden time jump, you can manually synchronize the time.

Linux (chrony)

  1. Stop chrony.

    sudo systemctl stop chronyd.service
  2. Manually synchronize the time.

    sudo chronyd -q
  3. Start chrony.

    sudo systemctl start chronyd.service

Linux (ntpd)

Alibaba Cloud Linux/CentOS/RHEL

  1. Stop ntpd.

    sudo service ntpd stop
  2. Manually synchronize the time.

    sudo service ntpdate start
  3. Start ntpd.

    sudo service ntpd start

Ubuntu/Debian

  1. Stop ntpd.

    sudo service ntp stop
  2. Manually synchronize the time.

    sudo ntpdate ntp.cloud.aliyuncs.com ntp7.cloud.aliyuncs.com ntp10.cloud.aliyuncs.com ntp11.cloud.aliyuncs.com ntp12.cloud.aliyuncs.com
  3. Start ntpd.

    sudo service ntp start

How do I ensure correct time synchronization across an ECS cluster?

By default, ECS Instances come pre-configured with the unified Alibaba Cloud NTP service and require no changes. When creating a custom NTP configuration for a cluster, we recommend using Cloud Assistant to apply changes in batches. This ensures consistency and avoids manual errors.

What are the Alibaba Cloud NTP server domain names?

The following table lists the Alibaba Cloud NTP server addresses for different networks (IPv4 only).

  • For Alibaba Cloud ECS Instances: Use the VPC internal network domains for lower network latency.

  • For non-Alibaba Cloud instances: Use the Internet 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

Is the Alibaba Cloud NTP service free of charge?

Yes, the Alibaba Cloud NTP service is free. Public images are pre-configured for time synchronization, and instances created from them automatically use chrony or ntpd to keep their time accurate.

How do I upgrading from ntpd to chrony?

Some older Alibaba Cloud ECS images, such as CentOS 6, use ntpd. Since ntpd is no longer actively maintained, we recommend upgrading to chrony unless your workload has a specific dependency on ntpd.

  1. Uninstall the ntp service.

    Alibaba Cloud Linux/CentOS/RHEL
    sudo yum remove ntp
    Ubuntu/Debian
    sudo apt remove ntp
  2. Install Chrony.

    If the download fails, see How to fix yum failures when installing chrony on CentOS 6 (EOL)?

    Alibaba Cloud Linux/CentOS/RHEL
    sudo yum install chrony
    Ubuntu/Debian
    sudo apt update sudo apt install chrony
  3. Configure Chrony.

    Edit the configuration file.

    Alibaba Cloud Linux/CentOS/RHEL

    sudo vim /etc/chrony.conf

    Ubuntu/Debian

    sudo vim /etc/chrony/chrony.conf

    Add NTP servers and other settings to the file. The following is a simple chrony.conf example:

    # 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.1

    Parameter descriptions:

    Parameter

    Description

    server <address>

    The domain name or IP address of the NTP server. chrony connects to this server to synchronize time.

    minpoll <n>

    The minimum polling interval, specified as a power of 2 in seconds. minpoll 4 means the minimum interval is 2⁴=16 seconds.

    maxpoll <n>

    The maximum polling interval, specified as a power of 2 in seconds. maxpoll 10 means the maximum interval is 2¹⁰=1024 seconds.

    iburst

    An option that speeds up the initial synchronization. When chrony starts, it sends a burst of requests to quickly achieve accurate time.

  4. Start the chrony service.

    1. Start the Chrony service 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
    2. Check the chrony service status.

      # Check the service status sudo service chronyd status
    3. Verify the time synchronization with the chronyc tool.

      sudo chronyc tracking

How to fix yum failures when installing chrony on CentOS 6 (EOL)?

  1. Back up and remove the old repo configuration files.

    sudo mkdir -p /etc/yum.repos.d/backup && sudo mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/
  2. Create a new repository configuration file that points to the official CentOS vault.

    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
  3. Clean and rebuild the yum cache.

    sudo yum clean all && sudo yum makecache
  4. Install chrony.

    sudo yum install chrony

Related documents

To learn more about Linux time concepts and operations, or to understand changes to time configurations in Linux Public Images, see Linux time and time zones.