Open In App

How To Set The Time Zone In Amazon EC2 ?

Last Updated : 06 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Amazon Elastic Compute Cloud (EC2) is a widely used cloud computing service that provides scalable computing capacity in the cloud. While deploying applications on EC2 instances, it is crucial to ensure that the system time is correctly set according to the desired time zone. This article will guide you through the process of setting the time zone on Amazon EC2 instances, covering essential concepts and providing a step-by-step walkthrough.

Primary Terminologies

  • Amazon EC2: Amazon Elastic Compute Cloud is a part of Amazon.com’s cloud-computing platform, Amazon Web Services, that allows users to rent virtual computers on which to run their computer applications.
  • Time Zone: A time zone is an area that observes a uniform standard time for legal, commercial, l and social purposes. Time zones tend to follow the boundaries between countries and their subdivisions instead of strictly following longitud because it is convenient for areas in frequent communication to keep the same time.

Setting Time Zone in Amazon EC2

Step 1: Connect to EC2 Instance

  • Use SSH to connect to your EC2 instance.(using .pem file to comunication sequre) or EC2 instance Dashboard in AWS cloud Console.
  • Select the check box of our Instance and go to Action and click on Connect to Connect the Instance.

Connecting to EC2 Instance

Step 2: Check the Current Time Zone

check the current time zone on running the following command on the EC2 Instance Console:

date
  • The following Amazon EC2 Console shows you clearly through practically:

AWS CLI Date command

Step 3: Backup Existing Configuration

  • It’s a good practice to back up existing configurations before making changes. For backing up use the following command:
sudo cp /etc/localtime /etc/localtime.bak

backing up the configuration file

Step 4: Selecting Time Zone

  • Run the following command to select your desired time zone. Replace “Region/City” with your specific region and city:
sudo ln -sf /usr/share/zoneinfo/Region/City /etc/local time

linking the time zone files

Step 5: Verifying The Time Zone Update

  • Confirm that the time zone has been updated correctly:
date

We have updated the time zone, to verify it run the `date` command in the CLI. The following screenshot illustrate clearly.

date is change UTC to EST

Time Zone Update in Amazon EC2 – FAQs

Can I Change The Time Zone Without Connecting To The EC2 Instance?

No, you need to connect to the EC2 instance via SSH or login in AWS console and then connect to instance to change the time zone.

How Often Should I Update The Time Zone On My EC2 instance?

Time zone updates are typically a one-time setup, unless there’s a need to change it.

What Happens If I Skip The Backup Step?

It’s recommended to back up the configuration to restore the original state if needed. Skipping this step might lead to difficulties in reverting changes.

Can I Set A Custom Time Zone Not Listed In /usr/share/zoneinfo?

No, you can only set time zones listed in the /usr/share/zoneinfo directory.

Will Changing The Time Zone Affect My Application’s Functionality?

In most cases, changing the time zone won’t impact application functionality, but it’s advised to test and verify.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads