WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [SOLVED] How to change timezone?  (Read 17948 times)

Offline kagashe

  • Full Member
  • ***
  • Posts: 129
    • My Tryst with Linux
[SOLVED] How to change timezone?
« on: January 07, 2009, 10:34:53 PM »
The time indicated by the clock is UTC.

I would like to change it to my timezone Kolkata (UTC+5:30). I looked at /usr/share/zoneinfo/Asia in which my city is not listed. I also find that /etc/localtime is not a symlink.

How to set it?

kagashe
« Last Edit: January 10, 2009, 05:03:14 AM by kagashe »

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
Re: How to change timezone?
« Reply #1 on: January 07, 2009, 10:45:22 PM »
What you can do is get hold of the latest timezone data tarball, extract the timezone you need and then make an extension of it/add it to your backup.

Once that is done, you can manually run the timezone update script from a terminal window or make your own script.

The timezone data extract is explained in linux-from-scratch or, if needed, I can dig out what I did in dsl to achieve the same thing

Offline kagashe

  • Full Member
  • ***
  • Posts: 129
    • My Tryst with Linux
Re: How to change timezone?
« Reply #2 on: January 08, 2009, 06:30:20 AM »
What you can do is get hold of the latest timezone data tarball, extract the timezone you need and then make an extension of it/add it to your backup.

Once that is done, you can manually run the timezone update script from a terminal window or make your own script.

The timezone data extract is explained in linux-from-scratch or, if needed, I can dig out what I did in dsl to achieve the same thing
I could not get any tarball on LFS, however, I downloaded Debian source package tzdata_2008i.orgig.tar.gz and extracted it but there is nothing to compile, then how to make tce? There are text files and one file is "Asia" which has Kolkata. How to use it?

I could not find any timezone update script on TC.

kagashe

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
Re: How to change timezone?
« Reply #3 on: January 08, 2009, 07:02:43 AM »
I'm stuck on a w2k machine at the moment, but it should go something like this:
Code: [Select]
$ sudo mkdir /tmp/tzdata
$ sudo chown tc:staff /tmp/tzdata
$ cd /tmp/tzdata
$ wget -c ftp://elsie.nci.nih.gov/pub/tzdata2008i.tar.gz
$ tar -zxvf tzdata2008i.tar.gz
$ zic -d zoneinfo asia [maybe Asia]
$ sudo cp zoneinfo/Asia/Kolkata /usr/share/zoneinfo/Asia/
$ sudo rm /etc/localtime
$ sudo cp /usr/share/zoneinfo/Asia/Kolkata /etc/localtime

To test if it works (make sure you have a network connection and that your hardware clock is set to GMT/UTC), I think you need:
Code: [Select]
$ sudo getTime.sh


Offline kagashe

  • Full Member
  • ***
  • Posts: 129
    • My Tryst with Linux
Re: How to change timezone?
« Reply #4 on: January 08, 2009, 07:32:28 AM »
Where is zic on TC? I have glib2 glib2-devs compiletc loaded.

kagashe

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
Re: How to change timezone?
« Reply #5 on: January 08, 2009, 08:10:05 AM »
Ah - good point, you get zic from compiling glibc.

Do you have access to a different linux distro where you can prepare your timezone file and then copy it across to tc?

Offline kagashe

  • Full Member
  • ***
  • Posts: 129
    • My Tryst with Linux
Re: How to change timezone?
« Reply #6 on: January 08, 2009, 08:52:28 AM »
Ah - good point, you get zic from compiling glibc.

Do you have access to a different linux distro where you can prepare your timezone file and then copy it across to tc?
Yes, I have Ubuntu Hardy, Debian Lenny, Arch.

kagashe

Offline kagashe

  • Full Member
  • ***
  • Posts: 129
    • My Tryst with Linux
Re: How to change timezone?
« Reply #7 on: January 08, 2009, 09:24:17 AM »
Ok. I got the hint and used zic on Ubuntu to prepare Kolkata file and copied it to /usr/share/zoneinfo/Asia and /etc/localtime.

However, running getTime.sh updates to UTC only and displayed time remains UTC.

kagashe

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
Re: How to change timezone?
« Reply #8 on: January 08, 2009, 09:51:26 AM »
You need to re-start jwm for the local time to be displayed

Offline kagashe

  • Full Member
  • ***
  • Posts: 129
    • My Tryst with Linux
Re: How to change timezone?
« Reply #9 on: January 08, 2009, 11:21:28 AM »
You need to re-start jwm for the local time to be displayed
I tried restarting jwm also xserver. The clock still displays UTC and date command also shows UTC time.

kagashe

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: How to change timezone?
« Reply #10 on: January 08, 2009, 11:47:52 AM »
Is the NIST server responding? When run from an xterm it should display both UTC and local.
local is specified via /etc/localtime

You may wish to use a more local time server.
The getTime.sh will accept a parameter of a time server nearer you.
See the script /usr/bin/getTime.sh. It is one that I converted from lua.
10+ Years Contributing to Linux Open Source Projects.

Offline kagashe

  • Full Member
  • ***
  • Posts: 129
    • My Tryst with Linux
Re: How to change timezone?
« Reply #11 on: January 09, 2009, 11:29:14 AM »
Assuming that the Kolkata file which I made on Ubuntu may not be working on TC, I tested the /usr/share/zoneinfo/Asia/Dubai file by linking it to /etc/localtime. It does not work, however, if I boot with tz=Asia/Dubai the clock displays Dubai time.

It is established that any link made to /etc/localtime after booting TC does not work.

I have working internet connection and "sudo getTime.sh" displays the following when I boot with tz=Asia/Dubai:
Fri Jan 9 16:21:30 UTC 2009
Fri Jan 9 20:21:30 GST 2009.

When I boot without tz=Asia/Dubai and change the timezone later by linking /etc/localtime to Dubai both lines display UTC only.

kagashe

Offline kagashe

  • Full Member
  • ***
  • Posts: 129
    • My Tryst with Linux
Re: How to change timezone?
« Reply #12 on: January 10, 2009, 05:02:37 AM »
This is happening on default TC boot (without any tz= option) only.

If I boot with any other tz= option (even tz=Asia/Kolkata which does not exist) the changes to /etc/localtime are honored.

I have added /usr/share/zoneinfo/Asia/Kolkata and /etc/localtime to /opt/.filetool.lst and it works for me.

This thread is solved but I have submitted a bug report.

kagashe
« Last Edit: January 10, 2009, 05:08:03 AM by kagashe »

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: [SOLVED] How to change timezone?
« Reply #13 on: January 10, 2009, 08:37:33 AM »
Just a comment. I notice that many posts contain instructions of adding system files to /opt/.filetool.lst.

While there is nothing wrong with it, it is not preferable.

The concept behind TC is modularity and the separation of static from dynamic data.

The preferred method would be to make a kolata.tce which contains the static system files and add it to your tce directory.

By doing this you keep the backup times shorter.
10+ Years Contributing to Linux Open Source Projects.

Offline tobiaus

  • Suspended
  • Hero Member
  • *****
  • Posts: 599
Re: [SOLVED] How to change timezone?
« Reply #14 on: January 10, 2009, 09:28:00 AM »
While there is nothing wrong with it, it is not preferable...

The preferred method would be to make a kolata.tce which contains the static system files and add it to your tce directory.

there's no question that your way is more ideal, it's not only faster, it is more likely to keep your tc setup working in the long run.

the ideal way would be "preferable" too, if it was not easier (more friendly) to add a line to filetool.lst than it was to create a .tce. creating a .tce is not the most complicated task, but i find myself putting off doing it this way, even though it was the way i originally planned to do everything (avoid filetool.lst completely!) but it turned out to be extremely friendly!

if there was ever a handy tool for making .tce's by simply giving it the name of a folder to "zip up," where the folder contained the proper structure (like the source directory for a dsl remaster does) then i think more people would do things the ideal way. the thing about adding to filetool.lst is, you don't even have to think about what you're doing so much. one line of text, there you go, it's added now. (but it's not ideal, just easy.)