AWS Tips and Tricks: Time Zone

By
Barry Stevens
May 31, 2016
AWS


While attempting to configure one of our AWS Linux servers I needed to do a few things that I have not had to do in the past and didn’t know how to do. I thought I would share some of those learnings.

Setting the timezone on AWS Linux EC2

I was setting up a server that users would be using to schedule some tasks so it needed to be in our local time zone to make it easier to schedule. AWS documentation is pretty detailed and I found this page, Setting the Time for Your Linux Instance.
Essentially you need to:

  1. Determine what time zone you want. The hierarchy of time zone files can be found in the /usr/share/zoneinfo.

I needed the “NZ”.

  1. Update the /etc/sysconfig/clock file. Because I was configuring this during start-up I used the following command in the User Data field of the instance (if you are doing it manually you’ll need to do with sudo as the clock file is owned by root).

sed -i.bak ‘s/ZONE=”UTC”/ZONE=”NZ”/’ /etc/sysconfig/clock

  1. Create a symbolic link between /etc/localtime and your selected time zone file. The command I used is below (again you may need to use sudo).

ln -sf /usr/share/zoneinfo/NZ /etc/localtime

  1. Reboot instance to ensure all services reference new time zone.


Time zone set. That’s it.
Barry, Preventer of Chaos

Barry Stevens is part of our Data Ops team who specialises in SAS Administration, helping you prevent chaos.

Connect with Barry on LinkedIn or read some of his other blogs here.

Copyright © 2019 OptimalBI LTD.