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

{ 37 comments… read them below or add one }

Gary July 5, 2012 at 5:53 am

Excellent post!
So simple when you know how to do it, other posts have had me copying files, deleting this, symlinking that. For linux nohoper this helped no end


Irish July 5, 2012 at 10:00 am

Thanks! Glad you found it helpful.


Andrew July 10, 2012 at 8:19 am

Thanks for the useful tip. Worked like a charm!


sagar October 22, 2012 at 2:20 pm

Thanks a lot. This helped


Emerson December 5, 2012 at 11:01 am

As simple as it must be! Great!


Shaun January 22, 2013 at 11:25 am

$ sudo service cron restart
is a nice one-line way to restart cron.


Irish January 22, 2013 at 11:34 am

Thx Shaun, ya Ubuntu tells me that every time is use the init.d scripts, but I always forget. lol ;-)


Vagner do Carmo December 25, 2014 at 2:36 pm

Very nice! :)


Jairo February 15, 2013 at 8:15 pm

Great tip!
Very well explained!


Joseph March 11, 2013 at 10:19 am

I’m still struggling with this.
My cronjobs are not running, and I believe it has something to do with the timezone. The machine was first built using AZ/Phoenix (GMT-7). I followed the above steps and made the system be GMT. After doing so, the following was returned:

root@tuxhyppx01:~# dpkg-reconfigure tzdata

Current default time zone: ‘Etc/GMT’
Local time is now: Mon Mar 11 17:08:59 GMT 2013.
Universal Time is now: Mon Mar 11 17:08:59 UTC 2013.


root@tuxhyppx01:~# date
Mon Mar 11 17:09:21 GMT 2013

I have a simple cronjob to test cron:

root@tuxhyppx01:~# crontab -l
16 17 * * * touch /tmp/file.txt

But nothing shows up in /tmp, and nothing in the logs.



Joseph March 11, 2013 at 10:54 am

Correction. Not sure why, but it just started working. I restarted cron– could that be it?
Please delete these 2 comments. All is good.


Irish March 11, 2013 at 11:01 am

Could be, I know if you change the timezone of the system you have to restart cron for it to pick that change up. But as far as it not running at all, I’m not sure. I know on Ubuntu as soon as you start up the OS cron starts automatically. So it could be OS dependent.


Manish May 6, 2013 at 3:59 am

Thanks buddy.


Kalil Maciel June 14, 2013 at 7:33 am

Man, this tip was awersome. Simple as it should be. Thanks


Vincenzo Romano June 19, 2013 at 8:54 am

You should also restart a number of other processes, not just cron.
Syslog (or any of its cousins) is one, otherwise you’ll get wrong timestamps.
Also the databases (if any).
Nonetheless this is a very good snippet.


Prasad July 27, 2013 at 4:53 am



André Fischer November 15, 2013 at 3:08 am

Thank you for this great time-saving tip! (And for the service cron restart one in the comments) I always forget that so much is available in various dpkg-reconfigure commands that saves headaches! :)


Julien January 29, 2014 at 7:53 pm

I also found out you can use a symlink, like so:

ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime



Leon January 31, 2014 at 12:50 am

Thanks mate.


Mau February 14, 2014 at 7:48 pm

Brilliant, clear and straight to the point. Thanks a bunch.


Christine Dorothy March 4, 2014 at 7:15 pm

Thank you so much for this instructions!


steve March 26, 2014 at 10:00 pm

Thanks! I don’t know what I’d do without people like you making my life easy!!! Seriously! a BIG thanks!

Reply April 4, 2014 at 12:08 pm

What’s up really just began writing programs with Ruby so I am
just a bit of a newbie! But found your site very helpful and informative.

Thanks for your time!


Rob April 17, 2014 at 6:47 pm

Thanks for this – made life simple :-)


kanny April 29, 2014 at 4:41 am

You saved my time… :)


Wesley April 29, 2014 at 6:45 am

Resolveu meu problema :)


Victor Kurauchi May 20, 2014 at 11:53 am

Great article, simple and efficient.

Helped a lot.


Jun May 21, 2014 at 8:39 am

Excellent job


Maxwell June 30, 2014 at 4:17 am

Thank you dude!
You saved my time.


Vachan Kumdule July 2, 2014 at 9:14 pm

Thank you for this. Such a simple task and so simply explained!!


Sultan July 14, 2014 at 10:51 pm

this is a nice tutorial. thanks for this tips…….. :)


Reginaldo Gomes October 29, 2014 at 7:08 am

Very good, Thanks!!!


Ndiritu N November 15, 2014 at 7:48 am



Miguel November 16, 2014 at 2:59 pm

Solution in one line:

sudo dpkg-reconfigure tzdata && sudo service cron restart

thanks for the post.


Nahm November 19, 2014 at 1:35 pm

Thanks for your post. It helped me reset time zone from Amazon Ec2 ubuntu instance which default time is in UTC. Thanks a lot, Nahm


Erik December 14, 2014 at 11:36 pm

Thank you for the great tutorial! ;)


Nihan Dip January 1, 2015 at 9:52 am

Thanks man!
You just made my day


Leave a Comment

{ 7 trackbacks }

Previous post:

Next post: