All Products
Search
Document Center

Elastic Compute Service:Precision clock and time synchronization on ECS instance

Last Updated:Oct 31, 2025

Time discrepancies can result in scheduled task errors, inconsistent log timestamps, and clock skew in distributed systems. To address these aspects, you can calibrate the time for your Elastic Compute Server (ECS) instance by configuring a clock synchronization service.

How it works

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

  • Alibaba Cloud NTP Server: Provides Virtual Private Cloud (VPC) endpoints that serve as highly accurate time sources for your ECS instances, allowing them to synchronize their system clocks with minimal network latency.

  • chrony/ntpd/W32time: Time synchronization services that use NTP to synchronize an instance's system clock with a time reference provided by an NTP server. On Linux/Unix systems, chrony offers better performance than ntpd. Windows systems use the built-in W32time service.

Verify clock accuracy

Quick guide

Linux (chrony)

ECS instances created from Alibaba Cloud public images run chrony by default. Some older public images run ntpd by default. To check which process is running, use ps -C chronyd,ntpd -o comm=. If the output is ntpd, see Linux (ntpd) tab.

Run the command below to check the clock offset. In the output, look for the System time field. Its value shows the current offset between your instance's system clock and the NTP time reference. In this example, 0.000027851 seconds fast of NTP time means the system clock is 0.000027851 seconds ahead of the NTP server time. If this offset exceed your application's tolerance, adjust your clock configuration.

To check the clock accuracy on multiple instances, use Cloud Assistant Batch Check.
sudo chronyc tracking
Reference ID    : 64643D58 (100.100.61.88)
Stratum         : 2
Ref time (UTC)  : Tue Oct 28 05:53:58 2025
System time     : 0.000027851 seconds fast of NTP time
Last offset     : +0.000044533 seconds
RMS offset      : 0.000036478 seconds
Frequency       : 41.053 ppm slow
Residual freq   : +0.000 ppm
Skew            : 0.007 ppm
Root delay      : 0.000408892 seconds
Root dispersion : 0.011003596 seconds
Update interval : 1028.9 seconds
Leap status     : Normal

Linux (ntpd)

Run the command below to check the clock offset. In the output, look for the offset field. Its value shows the difference between your instance's system clock and the NTP time reference, in milliseconds. Compare this offset with your application's tolerance. If it exceeds your application's tolerance, adjust your clock configuration.

To check the clock accuracy on multiple instances, use Cloud Assistant Batch Check.
sudo ntpq -p
remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 LOCAL(0)        .LOCL.          10 l  107   64    2    0.000    0.000   0.000
+47.96.XXX.XXX   100.100.61.91    2 u   37   64    3   31.241  1009.95   1.313
 11.116.XXX.XX   .INIT.          16 u    -   16    0    0.000    0.000   0.000
-100.100.3.1     10.137.55.181    2 u   52   64    7   25.344  1010.26   0.566
-100.100.3.2     10.137.55.181    2 u   18   64    7   26.873  1008.80   2.143
-100.100.3.3     10.137.55.181    2 u   66   64   12   29.656  1010.16   0.902
-203.107.6.88    10.137.55.181    2 u   65   64    7   33.689  1005.74   0.697
 11.196.XXX.XXX  .INIT.          16 u    -   16    0    0.000    0.000   0.000
 11.196.XXX.XX   .INIT.          16 u    -   16    0    0.000    0.000   0.000
 10.143.0.44     .INIT.          16 u    -   16    0    0.000    0.000   0.000
 10.143.0.45     .INIT.          16 u    -   16    0    0.000    0.000   0.000
 10.143.0.46     .INIT.          16 u    -   16    0    0.000    0.000   0.000
+100.100.5.1     203.107.X.XX     2 u   59   64    7   53.214  1009.42   0.519
*100.100.5.2     203.107.X.XX     2 u   58   64    7   49.062  1009.26   0.984
-100.100.5.3     203.107.X.XX     2 u   57   64    7   56.670  1011.81   3.331

Windows

Run w3tm /query /status command in the Command Prompt window. The Root Dispersion field in the output shows the current clock offset. In this example, 7.7612440s means the system clock is 7.7612440 seconds ahead of the NTP server time. If this offset exceed your application's tolerance, adjust your clock configuration.

To check the clock accuracy on multiple instances, use Cloud Assistant Batch Check.
Leap Indicator: 0(no warning)
Stratum: 3 (secondary reference - syncd via (S)NTP)
Precision: -23 (119.209ns per tick)
Root Delay: 0.0259591s
Root Dispersion: 7.7612440s
Reference ID: 0x64640302 (source IP:  100.100.3.2)
Last Successful Sync Time: 2025/10/28 15:05:02
Source: ntp11.cloud.aliyuncs.com,0x9
Poll Interval: 6 (64s)

Configure clock synchronization

Linux (chrony)

ECS instances created from Alibaba Cloud public images run chrony by default. Some older public images run ntpd by default. To check which process is running, use ps -C chronyd,ntpd -o comm=. If the output is ntpd, see Linux (ntpd) tab.

To configure clock synchronization on multiple instances, use Cloud Assistant Batch Execution.

1. Check and configure NTP server address

  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.

    Remove or comment out lines starting with server, then copy the following content into the configuration 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 and restart chrony.

    sudo systemctl restart chronyd.service

2. Verify clock synchronization

After restarting, verify the time synchronization metrics.

sudo chronyc tracking

The System time 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 clock.
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)

Certain legacy Alibaba Cloud public images, such as CentOS 6, are pre-configured with the ntpd service. Because the NTP service is no longer actively maintained, we recommend upgrading to Chrony for better performance and security.

To configure clock synchronization on multiple instances, use Cloud Assistant Batch Execution.

1. Check and configure NTP server addresses

  1. Edit the NTP configuration file.

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

    Remove or comment out lines starting with server, then copy the following content into the configuration file.

    Using multiple NTP servers provides redundancy and improves clock 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 and restart ntpd.

    Alibaba Cloud Linux/CentOS/RHEL

    sudo service ntpd restart

    Ubuntu/Debian

    service ntp restart

2. Verify clock synchronization

After restarting, verify the time synchronization metrics. Key parameters in the output:

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

  • jitter: The variation in time delay. A smaller value indicates more precise clock 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 clock.
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

Graphical user interface (GUI)

Change the default NTP server 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)

To configure clock synchronization on multiple instances, use Cloud Assistant Batch Execution.

1. Configure NTP servers

Change the default NTP server to an Alibaba Cloud NTP server. The following steps use Windows Server 2022 as an example.

  1. Open a Command Prompt window.

  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 clock with the NTP server.

    w32tm /resync

2. Verify clock synchronization

If the Source field in the output is Local CMOS Clock instead of the configured NTP server address, the synchronization has failed.

 w32tm /query /status
Leap 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,0x9
Poll Interval: 10 (1024s)

FAQ

How can I manually force a clock synchronization for Linux/Unix systems?

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

Linux (chrony)

  1. Stop chrony.

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

    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 clock.

    sudo service ntpdate start
  3. Start ntpd.

    sudo service ntpd start

Ubuntu/Debian

  1. Stop ntpd.

    sudo service ntp stop
  2. Manually synchronize the clock.

    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

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 domains for lower network latency.

  • For non-Alibaba Cloud instances: Use the Internet domains.

VPC domains

Internet domains

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 clock synchronization, and instances created from them automatically use chrony or ntpd to keep their clock accurate.

How do I upgrade 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 clock.

    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 clock 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

Reference

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