How to change time-zone on a Linux server

by admin on March 4, 2008 · 3 comments

in Settings

We run multiple websites on multiple servers so it’s fairly important that we can synchronise the time-zones on all these different boxes.

We found the Linux process of changing time-zone a little quirky, so we thought we would note it down here for future reference.

I think the following applies to most flavours of Linux, but we’re specifically using Ubuntu Dapper Drake in this example.

First of all, you’ll probably want to check the time and date on your box, to do this log-in via SSH and type the following command at the prompt:

date

You should then see the current time and date in this format:

Mon Aug 13 09:30:19 EDT 2007

OK, so let’s change our time-zone from EDT to something else. The server time-zone is controlled by a file called localtime, this file is a symbolic link to the specific time zone file. This file can be found in the etc/ folder, the specific time zone files can be found in usr/share/zoneinfo/. So, we just need to re-write the localtime sym link and re-point it. Working in the etc/ folder which contains localtime, type:

ln -sf /usr/share/zoneinfo/EST localtime

Now, when you check the time and date, you should that it now displays a different time and zone:

Mon Aug 13 06:45:02 PST 2007

There you have it, time-zone changed!

There are lots of options in the zoneinfo folder, take a look inside to see what you can use.

Related posts:

  1. Slicehost: a quick, fun way to learn Linux server administration
  2. Rotate Apache log files on Ubuntu Hardy Heron server
  3. Ubuntu server distro direct-upgrade
  4. Number 1, all-time, best, most-effective link-building tip ever, ever!
  5. T-shirt sellers and big brands alike jump on CHANGE band wagon

{ 1 trackback }

How to change timezone for server?
October 18, 2008 at 12:07 pm

{ 2 comments… read them below or add one }

1 Afsar March 9, 2009 at 11:21 pm

I am trying this ..but i am getting Error permission denied …please suggest

Reply

2 JC March 10, 2009 at 7:31 am

Use sudo before the command that is failing.

Reply

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Next post: