You need to enable JavaScript to run this app.
Elastic Compute Service

Elastic Compute Service

Copy page
Download PDF
ECS instance local time synchronization
Configuring Chrony service for Linux instances (CentOS 7)
Copy page
Download PDF
Configuring Chrony service for Linux instances (CentOS 7)
This topic describes how to modify the time zone of a Linux ECS instance, as well as how to enable, configure, and use the Chrony service to ensure accurate local time synchronization for the instance. In the example provided in this topic, CentOS 7.9 is used.​
About Chrony​
Chrony is a general-purpose implementation of the Network Time Protocol (NTP). In CentOS 7, you can use the Chrony tool to synchronize the local time with standard time, minimizing time and frequency discrepancies to the greatest extent possible. Chrony is also particularly useful for systems that do not run continuously or operate on virtual machines. For more information, see Chrony.​
Prerequisites​
  • CentOS 7 comes with Chrony preinstalled. If not, install it by executing the yum install chrony -y command.​
  • Chrony uses the User Datagram Protocol (UDP) to send and receive timestamps over port 123. Make sure that an inbound rule is added to the security group of the instance to allow inbound traffic on UDP port 123. For more information, see Creating security groups.​
Procedure​
Modify the time zone of a Linux instance​
  1. Connect to the Linux instance. For more information, refer to Logging in to Linux instances.​
  1. Execute the following command to view the list of time zones.​
  • ​
    ls /usr/share/zoneinfo/<时区文件夹名称>​
    ​
  • For example, you can execute the following command to view the list of time zones in Asia.​
  • ​
    ls /usr/share/zoneinfo/Asia​
    ​
  1. Execute the following command to modify the time zone. In the example provided in this topic, the time zone is changed to Shanghai.​
  • ​
    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime​
    ​
  1. Execute the following command to update the Real-Time Clock (RTC).​
  • ​
    hwclock -w​
    ​
  1. Execute the following command to view the time zone.​
  • ​
    timedatectl status​
    ​
  1. If the following query result is displayed, the time zone is changed to Shanghai.​
  • ​
    Local time: Sat 2022-10-08 03:26:16 UTC ​
    Universal time: Sat 2022-10-08 03:26:16 UTC​
    RTC time: Sat 2022-10-08 03:26:16​
    Time zone: Asia/Shanghai (UTC, +0800)​
    ​
Enable the Chrony service​
  1. Connect to the Linux instance. For more information, refer to Logging in to Linux instances.​
  1. Execute the following commands to start the chronyd service and specify that the service automatically starts upon instance startup.​
  • ​
    systemctl start chronyd.service​
    systemctl enable chronyd.service​
    ​
  1. Execute the following command to view the time synchronization status of the ECS instance and verify whether the service is started.​
  • ​
    chronyc tracking​
    ​
  1. Execute the following command to view the list of time synchronization servers.​
  • ​
    chronyc -n sources -v​
    ​
Configure the Chrony service​
  1. Connect to the Linux instance. For more information, refer to Logging in to Linux instances.​
  1. Execute the following command to open the chrony configuration file. For more information about the chrony.conf file, see chrony.conf.​
  • ​
    vim /etc/chrony.conf​
    ​
  1. Press the i key to start editing the file. Delete any unnecessary NTP server lines, or add a # at the beginning of the lines to comment them out.​
  1. Add the required NTP servers. After you complete the editing, press the Esc key to exit edit mode, enter :wq, and then press Enter to save and exit the file.​
Volcano Engine provides NTP servers. For more information, see List of Volcano Engine NTP server addresses.​
  • ​
    server ntp0.ivolces.com minpoll 4 maxpoll 10 iburst​
    server ntp1.ivolces.com minpoll 4 maxpoll 10 iburst​
    server ntp2.ivolces.com minpoll 4 maxpoll 10 iburst​
    server ntp3.ivolces.com minpoll 4 maxpoll 10 iburst​
    ​
  1. Execute the following commands to start the chronyd service and specify that the service automatically starts upon instance startup.​
  • ​
    systemctl start chronyd.service​
    systemctl enable chronyd.service​
    ​
  1. Execute the following command to view the list of time synchronization servers.​
  • ​
    chronyc -n sources -v​
    ​
Manually synchronize the clock by using Chrony​
  1. Connect to the Linux instance. For more information, refer to Logging in to Linux instances.​
  1. Execute the following command to enter the Chrony tool.​
  • ​
    chronyc​
    ​
  1. In the Chrony tool, execute the following command to synchronize the clock.​
You can execute the help command to obtain usage instructions for common Chrony commands.​
  • ​
    makestep​
    ​
​
Last updated: 2026.06.17 19:32:52