1

Usually /etc/timezone is a text file containing the timezone, at least that's how it works on most non-embedded linux distros. However, on Amazon Linux(4.14.72-68.55.amzn1.x86_64) it's actually an empty directory.

$ ls -la /etc/{timezone,localtime}
-rw-r--r-- 1 root root  118 Aug 11 01:27 /etc/localtime

/etc/timezone:
total 8
drwxr-xr-x  2 root root 4096 Oct 22 09:53 .
drwxr-xr-x 93 root root 4096 Oct 22 09:53 ..


$ ll /usr/share/zoneinfo/
total 416
drwxr-xr-x  2 root root   4096 Aug 11 01:26 Africa
drwxr-xr-x  6 root root   4096 Aug 11 01:26 America
drwxr-xr-x  2 root root   4096 Aug 11 01:26 Antarctica
drwxr-xr-x  2 root root   4096 Aug 11 01:26 Arctic
drwxr-xr-x  2 root root   4096 Aug 11 01:26 Asia
drwxr-xr-x  2 root root   4096 Aug 11 01:26 Atlantic
drwxr-xr-x  2 root root   4096 Aug 11 01:26 Australia
drwxr-xr-x  2 root root   4096 Aug 11 01:26 Brazil
drwxr-xr-x  2 root root   4096 Aug 11 01:26 Canada
-rw-r--r--  1 root root   2102 Apr  4  2018 CET
drwxr-xr-x  2 root root   4096 Aug 11 01:26 Chile
-rw-r--r--  1 root root   2294 Apr  4  2018 CST6CDT
-rw-r--r--  2 root root   2411 Apr  4  2018 Cuba
-rw-r--r--  1 root root   1876 Apr  4  2018 EET
[...]

What would be the equivalent for scripts that rely on reading /etc/timezone? Is it safe to delete the dir and create a file with <Region>/<City>?

dimid
  • 617
  • 6
  • 14
  • Could you post the contents of `/usr/share/zoneinfo`? – Surya Teja Karra Oct 31 '18 at 11:46
  • Sure, anything specific? It's rather long. – dimid Oct 31 '18 at 11:59
  • Nope, just wanted to make sure this directory is populated with files (like in any other distro). Since Amazon Linux appears to be using yum which is used on RHEL, Fedora and its derivatives, have you tried `timedatectl list-timezones` and `timedatectl set-timezone xxx`? – Surya Teja Karra Oct 31 '18 at 12:08
  • `-bash: timedatectl: command not found` – dimid Oct 31 '18 at 12:14
  • `/etc/localtime` is often just a symlink to one of the files in `/usr/share/zoneinfo`. The systems that I work with don't have an `/etc/timezone`. – larsks Oct 31 '18 at 13:37

1 Answers1

0

AWS Docs for Timezone change

I'd check here for a start. This is pretty good documentation. Amazon Linux has its set of instructions near the bottom.

As you noted, you can check [ec2-user ~]$ ls /usr/share/zoneinfo for the list of acceptable timezones.

You are likely running into the issue where it complains about the command because you're not running as a privileged user.

Try something like this: [ec2-user ~]$ sudo timedatectl set-timezone America/Vancouver

jwhaley58
  • 101
  • 1