Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

Make sure the time zone is also changed in

/etc/sysconfig/clock
by setting

ZONE="America/New_York"
share|improve this answer
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 Nov 6 '12 at 17:26
1  
Changing only the ZONE will suffice –  kernelpanic Nov 6 '12 at 17:48
    
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 Aug 8 at 17:01

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
share|improve this answer
    
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 Nov 7 '12 at 18:40
    
Let me know if it turns out you don't need it, I might be setting it false unnecessarily. –  Jason Floyd Nov 10 '12 at 5:33
    
EC2 hardware clocks are in UTC so the UTC=false line shouldn't be added. –  Jason Floyd Nov 10 '12 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 Nov 12 '12 at 18:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.