How to set the time zone in Amazon EC2?

后端 未结 11 1436
迷失自我
迷失自我 2020-12-22 19:33

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

11条回答
  •  执念已碎
    2020-12-22 19:55

    When you create a new EC2 instance and select "Amazon Linux 2 AMI (HVM)" as Amazon Machine Image (AMI), you can insert these lines in the "User Data" section. Based on which region you are in, change the second line with the timezone that works for you. I am in Central European Time (CET). Bear in mind that this bootstrap code is executed as root and only once when the instance is created.

    #!/bin/bash
    rm -rf /etc/localtime
    ln -s /usr/share/zoneinfo/CET /etc/localtime
    

    If you want to see all the other timezones available, ssh to one instance and run:

    ls /usr/share/zoneinfo
    

提交回复
热议问题