How do I manage the clock source for EC2 instances running Linux?
"How can I determine the clock source used by an Amazon Elastic Compute Cloud (Amazon EC2) instance running Linux, and how can I change it?"
"How can I determine the clock source used by an Amazon Elastic Compute Cloud (Amazon EC2) instance running Linux, and how can I change it?Short descriptionBy using an SSH client, you can find the current clock source, list the available clock sources, or change the clock source.Note: There are many clock sources available for Hardware Virtual Machine (HVM) instances, such as Xen, Time Stamp Counter (TSC), High Precision Event Time (HPET), or Advanced Configuration and Power Interface Specification (ACPI). For EC2 instances launched on the AWS Xen Hypervisor, it's a best practice to use the tsc clock source. Other EC2 instance types, such as C5 or M5, use the AWS Nitro Hypervisor. The recommended clock source for the AWS Nitro Hypervisor is kvm-clock.Note: AWS Graviton2 processors use arch_sys_counter as the clock source.ResolutionTo find the clock sourceOpen an SSH client into your EC2 instance, and then run the following commands to find the current and available clock sources.To find the currently set clock source, list the contents of the current_clocksource file:cat /sys/devices/system/clocksource/clocksource0/current_clocksourcexenTo list the available clock sources, list the contents of the available_clocksource file:cat /sys/devices/system/clocksource/clocksource0/available_clocksourcexen tsc hpet acpi_pmTo set the current clock source to a different value1.    Run bash as a superuser to override the current_clocksource:sudo bash -c 'echo tsc > /sys/devices/system/clocksource/clocksource0/current_clocksource'2.    Run the dmesg command to view the kernel messages:dmesg | lessIf the override was successful, this message appears:clocksource: Switched to clocksource tscNote: Rebooting the system causes the Linux kernel to reset the clock source.To permanently set the clock sourceTo permanently set the clock source, set the source in the system boot loader:1.    Set clocksource in the kernel command line parameter.For example, if you use grub2 and you want to set the clock source to "tsc", open /etc/default/grub in an editor. Then, add clocksource=tsc tsc=reliable for the GRUB_CMDLINE_LINUX option:GRUB_CMDLINE_LINUX="console=tty0 crashkernel=auto console=ttyS0,115200 clocksource=tsc tsc=reliable"2.    Generate the grub.cfg file:grub2-mkconfig -o /boot/grub2/grub.cfgRelated informationSet the time for your Linux instanceFollow"