How to Manage Linux Server Timezone Settings

edited August 2014 in Proposed How-Tos
Setting your date and time correctly on your Linux server is very important. Your server logs and other important information will all reflect the timezone of your server. In most cases, you will want to set your server’s time to match your own local time, but if your server is remote or hosting sites for people primarily located in another timezone, you might choose a different one.

On Red Hat Enterprise Linux or CentOS, you can use the setup program or redhat-config-date to set the timezone. The setup program, although run from the command line, uses a semi-graphical interface to make it easier.

On a Debian-based distribution, use dpkg-reconfigure tzdata to set the timezone.

With all of these commands, they will include onscreen instructions that will walk you through the process. Once you have changed the time, you can verify that your settings are correct by running “date”. For example:

$ date

Thu Apr 17 14:47:12 EDT 2014

In the case of my system, it is 2:47 PM on Thursday April, 17 2014, and the timezone is Eastern Daylight Time.

Comments

  • Should note that when it asks 'is your hardware clock set to UTC' to answer yes. You can also just symlink /etc/localtime to the appropriate file under /usr/share/zoneinfo.

    Perhaps also worth mentioning that each user can have their own timezone set (or even per process) with the TZ environment variable.

    Also advisable to set up ntp or some such to keep your time in check.

    Cheers,
    Andrew
  • edited August 2014
    "Qhigh", as Andrew touches upon above, the timezone is not related to the server time.

    Unlike Windows, Unix systems run internally on the UTC timezone. (Ignoring the kludge that exists so that a unix OS can co-exist with a windows OS on a dual-booting system), and all timestamps are stored as such.

    When you set the timezone, you are just configuring the default offset that will be used for *display* purposes, and as Andrew points out, any user (or more precisely, as he says, any process) can set it's own timezone string.

    So, yeah, good tips about setting the date etc. for logs etc. but timezone is a different beast than can be set/altered after the event, and because all stored date/time are in a standard universal timezone, when displayed, they will all adapt automatically to whatever your timezone is currently set it to.

    Also, +1 to NTP .......... :-)
  • Not just for *display* purposes. E.g. Cron.
  • Yes! Oops. Good catch!
Sign In or Register to comment.