How to set the time zone in Amazon EC2?

2020-02-16 06:09发布

I want to change the time zone set in my Amazon EC2 instance running Ubuntu Linux to local time?

My Question

How to change the time zone in Amazon EC2?

11条回答
放荡不羁爱自由
2楼-- · 2020-02-16 06:24

UPDATED ANSWER FOR UBUNTU 16.04:

Do:

sudo timedatectl set-timezone America/New_York

to update your timezone.

To list down all the available timezones you can do:

timedatectl list-timezones
查看更多
The star\"
3楼-- · 2020-02-16 06:27

Another way of changing the time (This was done on an Amazon EC2 Linux instance)

Remove your localtime file

sudo rm /etc/localtime

Change Directory to ZoneInfo

cd /usr/share/zoneinfo

This folder contains all of the timezone information. You then just need to softlink to the appropriate zone.

Create a softlink to /etc/localtime

sudo ln -s /usr/share/zoneinfo/GB /etc/localtime

That will change your server timezone to GB

查看更多
【Aperson】
4楼-- · 2020-02-16 06:27

None of the above steps worked for me, so thought of writing this new answer here

# Delete any existing localtime link
sudo rm /etc/localtime
# Update time clock file with ZONE property
sudo vi /etc/sysconfig/clock
#Update the ZONE property to what you want say
ZONE="America/Los_Angeles"
sudo ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
sudo reboot
查看更多
虎瘦雄心在
5楼-- · 2020-02-16 06:28

NOTE: This refers to a linux box (debian in my instance) should be used under your AWS launch configurations "User Data".

If you're planning to set the TIMEZONE on instance boot use below (works like a charm) use you're own Country/City instead of "Australia/Sydney".

#!/bin/bash

/bin/rm -f /etc/localtime; /bin/ln -s /usr/share/zoneinfo/Australia/Sydney /etc/localtime
查看更多
Juvenile、少年°
7楼-- · 2020-02-16 06:33

Locate your timezone in the directory /usr/share/zoneinfo/.

E.g. To change timezone for Toronto /usr/share/zoneinfo/America/Toronto

Symlink your timezone to /etc/localtime e.g. for Toronto:

sudo ln -sf /usr/share/zoneinfo/America/Toronto /etc/localtime

Reboot to finish

reboot
查看更多
登录 后发表回答