LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Cannot change timezone on Slackware 13.37 (https://www.linuxquestions.org/questions/slackware-14/cannot-change-timezone-on-slackware-13-37-a-943520/)

hoyortsetseg 05-06-2012 09:49 AM

Cannot change timezone on Slackware 13.37
 
Hi,

This is not a question. Just some problem I solved and thought I could share it here if someone has the same problem. I considered posting this on General > success stories but on second thought it did not seem like that much of a success and the problem might be Slackware specific. Feel free to move this if it doesn't fit here. But there's still a mystery to be solved. See the bottom of the post.

I am running Slackware 13.37. Since I installed Slackware on this computer in 2007 I have never formatted or reinstalled the OS. I just upgraded as described (might be related).

I recently moved several timezones away from my hometown so I wanted to change the timezone setting.

Changing the timezone looked fairly easy according to a simple web search.

Delete /etc/localtime
Code:

sudo rm -f /etc/localtime
Make a symlink to your new timezone
Code:

sudo ln -s /usr/share/zoneinfo/<your_continent>/<your_zone> /etc/localtime
(some sources used ln -sf)

Check if you were able to change the timezone with "date".
Code:

date
Set the time with "date"
(Omitting this because I cannot look up the string format again)

If your hardware clock is set to local time write this new local time to hardware clock
Code:

sudo /sbin/hwclock --systohc
My problem: the symlinking step did not appear to work. After creating the symlink and checking the timezone with "date", I saw that the timezone remained the same as that of my hometown. Instead of sudoing I tried again as root to no avail.

My solution: Out of desperation I looked at the content of timezone files in /usr/share/zoneinfo. They are mostly gibberish, but in the last line you can make out the timezone abbreviations. I checked several files and saw that the timezone abbreviations were the same as that of my hometown timezone. Weird.

So I decided to reinstall glibc-zoneinfo which has the timezone lists and information.

Code:

sudo /usr/sbin/slackpkg reinstall glibc-zoneinfo
When slackpkg prompted I chose the "overwrite" option.

After this, the steps I described above worked smoothly. My timezone is correct, time is correct.

Mystery: Out of curiosity I looked at the contents of the new timezone files in /usr/share/zoneinfo. They all had the correct timezone abbreviations in their last lines. What struck me was that these files were much shorter than my original timezone files. I don't know how I messed them up, how they ended up much longer then they were supposed to be.

ponce 05-06-2012 10:15 AM

to change the timezone you can also run
Code:

timeconfig
if you want to sync once with a timeserver
Code:

ntpdate pool.ntp.org
to write the date to the system clock
Code:

hwclock -w

hoyortsetseg 05-06-2012 10:41 AM

Thank you ponce.

I did try timeconfig as well. That did not work either. It must be using the files in /usr/share/zoneinfo.

What I don't get is how I managed to mess those zoneinfo files up in the first place. If they had been OK, symlinking would have worked, timeconfig would have worked.

Maybe the morale of this thread is, if you can't change the timezone no matter what you do, it might serve to check the content of the zoneinfo files. In my case, this is what solved my problem.

kabamaru 05-07-2012 02:24 AM

Maybe this wouldn't work in your case, due to the symlinking problem, but FWIW Slackware provides a super easy way to select your timezone:

pkgtool > Setup > Select Your Timezone

hoyortsetseg 05-07-2012 03:22 AM

I am marking this "solved" but the mystery remains. Any idea on how the zoninfo files were messed up would be appreciated.

astrogeek 05-07-2012 04:04 AM

Quote:

Originally Posted by hoyortsetseg (Post 4672178)
I am marking this "solved" but the mystery remains. Any idea on how the zoninfo files were messed up would be appreciated.

Just a guess - I have not researched this...

Sometime in the last few years when the rules for daylight-saving time changed in the US (other places as well?), it was necessary to update those files. I also have a vague memory that the format of some time related files changed at or around that time.

I had some fits sorting it out at the time on different machines and distinctly remember noticing that the new files were signifigantly smaller than the old ones, which was a concern at the time.

Maybe your version updates failed to pick those up for some reason...

Hope this is more helpful than confusing.

tronayne 05-07-2012 05:07 AM

Have you applied all the patches? There have been more than a couple that affect the zoneinfo files (see http://ftp.osuosl.org/pub/slackware/.../ChangeLog.txt); the link is to Slackware-64 but the same changes apply to 32-bit.

Slackware.com appears to be down; you can download patches from (64-bit) http://ftp.osuosl.org/pub/slackware/...ches/packages/ or (32-bit) http://ftp.osuosl.org/pub/slackware/...ches/packages/. Just use
Code:

upgradepkg *.t?z
once you've got all the current patch levels (I use wget to get 'em all into a directory then run upgradepkg, YMMV).

Hope this helps some.

chandan_raka 06-07-2012 06:47 PM

[SOLVED] Cannot change timezone on Slackware 13.37
 
this technique works for I guess most destro.

In centos I did yum reinstall tzdata then copied the zonefile as localtime @/etc and it worked

volkerdi 06-07-2012 08:03 PM

Another thing to consider is that if /usr is on its own partition, it's not going to be there when the clock is set in /etc/rc.d/rc.S. That's why timeconfig makes a copy of the zoneinfo file as /etc/localtime (and leaves an otherwise unused /etc/localtime-copied-from symlink in /etc to document what the current timezone is).

That's probably not the issue here, but is something to be aware of regarding the instructions that were found online.

slowpaxi 10-28-2012 10:29 AM

Quote:

Originally Posted by ponce (Post 4671634)
to change the timezone you can also run
Code:

timeconfig
if you want to sync once with a timeserver
Code:

ntpdate pool.ntp.org
to write the date to the system clock
Code:

hwclock -w

Ponce you are always concise and helpful. Thank you.
Altro che "Ponce"!!! :)

ChrisAbela 10-29-2012 03:44 PM

ntpdate is being retired.

On the Gentoo wiki http://en.gentoo-wiki.com/wiki/NTP , they recommend something like:

# sntp -s pool.ntp.org

and it works on Slackware too.


All times are GMT -5. The time now is 01:05 PM.