How to set the timezone on Ubuntu Server

by Irish on March 21, 2012

I find it’s pretty annoying when you have to go log file spelunking only to find all the timestamps are in UTC.  But we can set the timezone of the server so when Rails, cron, scripts, etc run, they output more readable dates.

You can check your current timezone by just running

$ date
Thu Mar 21 18:02:49 MST 2012

Or checking the timezone file at

$ more /etc/timezone

So to change it just run

$ sudo dpkg-reconfigure tzdata

And follow on screen instructions.  Easy.

Also be sure to restart cron as it won’t pick up the timezone change and will still be running on UTC.

$ /etc/init.d/cron stop
$ /etc/init.d/cron start

UPDATE July 2016
In the comments Dan mentions that in 16.04 you use something like:

$ sudo timedatectl set-timezone Australia/Melbourne

Previous post:

Next post: