Guided Lab: Setting Amazon Time Sync Service for Amazon EC2 Linux Instance
Description
Accurate timekeeping is crucial for the proper functioning of many applications and services running on cloud infrastructure. This includes logging events, coordinating distributed processes, and ensuring the security of communications through protocols that rely on synchronized time, such as TLS/SSL. In the AWS ecosystem, ensuring your EC2 instances have the correct time is vital for seamless operation and accurate billing.
This guided lab will walk you through the process of configuring and managing time synchronization on a Linux instance running in Amazon EC2. You will learn how to use the Network Time Protocol (NTP) with Chrony, a versatile and powerful time synchronization tool, which is the default for many modern Linux distributions. By following these steps, you will ensure your EC2 instance maintains accurate time, improving the reliability and accuracy of time-dependent processes and logs.
Prerequisites
This lab assumes you have basic knowledge of Linux command-line operations and Amazon EC2 service.
If you find any gaps in your knowledge, consider taking the following lab:
Objectives
In this lab, you will:
- Verify and configure time synchronization on a Linux EC2 instance.
- Understand the use of NTP and Chrony to maintain accurate time.
- Ensure your instance’s time is correctly synchronized with time servers.
Lab Steps
Launch an EC2 Instance
1. Navigate the EC2 Dashboard.

2.Launch an EC2 Instances using the following configurations:
- Name: MyWebServer
- AMI: Amazon Linux
- Instance type: t2.micro
- Key pair: (Please create a new one.)
- Key pair name: my-key-pair
- Key pair type: RSA
- Private key file format: .pem
- Network settings:
- Auto-assign public IP: Select Enable
- Firewall (security groups): tick on the Create security group
- Ensure that Allow SSH traffic from is checked and is My IP

- Click on Launch instance
Verify Current Time and Time Zone
1. SSH into your newly created EC2 instance.

2. Check the current system time and time zone, using the commands:
date
timedatectl

Take note these date and time details, and lets compare what’s the difference later on.
Install and Configure Chrony
1. Ensure that Chrony is installed on your instance. If not, install it using the package manager, using the command:
sudo yum install chrony -y

2. Enable and start the Chrony service:
sudo systemctl enable chronyd
sudo systemctl start chronyd

3. Verify the Chrony service status:
sudo systemctl status chronyd

4.(OPTIONAL) Configure Chrony by editing the configuration file /etc/chrony.conf (optional, if you need to change the default NTP servers or settings):
sudo vi /etc/chrony.conf
5. Verify Time Synchronization by checking the Chrony tracking and sources:
chronyc tracking
chronyc sources -v

Set the Correct Time Zone
1. List available time zones:
timedatectl list-timezones

Hit ENTER to check the check the other timezones or next page
Click on CTRL + C to exit
2. Set your desired time zone (e.g., Asia/Manila):
sudo timedatectl set-timezone Asia/Manila

3. Verify the changes:
timedatectl

That’s it! You have successfully configured time synchronization on your Linux EC2 instance using Chrony. Ensuring accurate time synchronization is essential for maintaining system logs, data consistency, and secure communications. You have also learned how to set the correct time zone for your instance. Regularly verifying and managing time settings is a good practice to ensure the smooth operation of your applications and services.
Accurate timekeeping helps in diagnosing issues by providing reliable timestamps in logs, facilitates seamless coordination across distributed systems, and ensures the integrity and security of communications and transactions. Regularly verifying and managing time settings is a good practice to ensure the smooth operation of your applications and services.
By mastering these skills, you can enhance the reliability and performance of your cloud infrastructure, making sure your systems are always operating with precise time synchronization. Continue to apply these practices in your future deployments and maintenance tasks to maintain optimal system health. Happy Learning!