8

I use an Amazon EC2 server instance that runs a distro called Amazon Linux AMI. (I've read that it is based on CentOS/Red Hat). My specific version is the 2012.09 release.

Anyway, I was able to change the time zone about a week ago from the default UTC to America/New_York (which is EST/EDT). The command I used to change it was:

    ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime

...thanks to this other Server Fault question. At that point, I was able to run date from the the command line, and it correctly displayed the EDT time. And even after EDT "fell back" to EST this past Sunday, I was pleased to find that running date still produced the correct local time. So that was great.

However, after running a yum update yesterday, it seems that my time zone got reverted back to plain 'ol UTC. I even checked the last modified time of /etc/localtime file, and indeed it confirmed that it had been modified around the same time I had updated.

Is there any way to prevent this from happening again, or will I be stuck resetting the time zone every time I do a yum update?

2 Answers 2

7

Make sure the time zone is also changed in

/etc/sysconfig/clock
by setting

ZONE="America/New_York"
4
  • 1
    Thanks so much for the reply. I plan to accept your post if, after implementing your changes and running a yum update (when updates are available of course) my time zone does not revert. In the meantime, I checked /etc/sysconfig/clock and it has ZONE="UTC" and UTC=true. Do i need to make it say UTC=false? or do I only change ZONE?
    – D.Tate
    Commented Nov 6, 2012 at 17:26
  • 1
    Changing only the ZONE will suffice Commented Nov 6, 2012 at 17:48
  • 1
    I am having the same issue. I changed the timezone in /etc/timezone but it reverts back to UTC every time I log out of the server. And for whatever reason /etc/sysconfig doesn't exist for me, so I can't modify the clock file. Any hints?
    – sixty4bit
    Commented Aug 8, 2014 at 17:01
  • What will for IST, I wrote ZONE="Indian", but it's not working.
    – Samir
    Commented Apr 30, 2019 at 9:47
0

Here's what I run on mine to keep them in Pacific Time:

sed -i '/ZONE/c \ZONE="America\/Los_Angeles"' /etc/sysconfig/clock
ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
4
  • Thanks for the script Jason. kernelpanic mentioned that UTC=false is not necessary. If, after my testing, I find that it is necessary, I may very well mark your answer as the accepted one.
    – D.Tate
    Commented Nov 7, 2012 at 18:40
  • Let me know if it turns out you don't need it, I might be setting it false unnecessarily. Commented Nov 10, 2012 at 5:33
  • EC2 hardware clocks are in UTC so the UTC=false line shouldn't be added. Commented Nov 10, 2012 at 8:04
  • Thanks for the clarification Jason. I'm not sure if changing UTC to false will prevent the correct local time from displaying or not, but regardless, just leaving it at the default value of UTC=true seemed to be fine for me. If you want to "experiment" with various settings, I was able to test updates using yum history undo [a number] command. I would test date before and after the undo to see if it retained EST
    – D.Tate
    Commented Nov 12, 2012 at 18:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .