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
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