Dreamhost seems to think that we like PDT, despite being in the Midwest. How do I change the timezone?
This is presumably a bit late for the OP, and more intended for other searchers who arrive here.
If you need a non-interactive solution, try this solution from changing timezone with dpkg-reconfigure tzdata and debconf-set-selections
echo "Europe/Zurich" > /etc/timezone dpkg-reconfigure -f noninteractive tzdata
You can figure out your timezone by poking around in /usr/share/zoneinfo. In fact the dpkg-reconfigure command above copies the appropriate file from there to /etc/localtime. I used to just do that manually, and it seems to work fine.
Don't be too surprised if long running processes don't pick up the change. eg Apache log timestamps come to mind. Consider whether that matters, and hence whether you need to restart running processes or even reboot.
To edit it non interactively on recent Debian and Ubuntu versions (Stretch/Xenial etc.), you need to remove
/etc/localtime as well, otherwise
/etc/timezone will be overwritten.
echo 'Europe/Zurich' > /etc/timezone rm /etc/localtime dpkg-reconfigure -f noninteractive tzdata
This answer is based on mc0e' answer. I can not add a comment with my reputation.
echo "TZ=Etc/UTC" >> /etc/environment tzconfig
Etc/UTC is your preferred timezone you found using
When you're using
the timezone information is not kept after reboot. You can verify your settings with
diff -s /etc/localtime /usr/share/zoneinfo/`cat /etc/timezone`
If you're only updating
/etc/timezone, the update won't be consistent with
/etc/localtime, thus it's better to execute
tzselect to find out which time zones actually exists (or simply browse
In POSIX systems the
TZ should take precedence before
export TZ='Europe/Berlin' $ date Tue Apr 10 08:51:03 CEST 2018 export TZ='Pacific/Efate' $ date Tue Apr 10 18:28:33 +11 2018
TZ can save you many system calls as frequently used date/time related functions has to access filesystem each time some program asks for current date. It's a micro-optimization, but quite simple one.