LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Set time?? (https://www.linuxquestions.org/questions/slackware-14/set-time-826616/)

spoovy 08-16-2010 04:52 PM

Set time??
 
I have tried all sorts of commands - hwclock, clock, date, and timeconfig. Nothing seems to really sort out my problem.

I am in London, UK, but when i set the clock with timeconfig it still sets the time to GMT (London time) -1 hour. I can set it back with date --set=(time) but this reverts with each new session back to GMT -1. I have spent ages googling around on this and tried several different methods but i'm still stuck!

Anyone want to help me out?

Thanks in advance

Spoov

Richard Cranium 08-16-2010 05:14 PM

What version Slackware?

What does
Code:

ls -l /etc/localtime-copied-from
give you?

Do the two commands
Code:

sha1sum /etc/localtime-copied-from
sha1sum /etc/localtime

give the same hash values?

GazL 08-16-2010 05:30 PM

For the UK you want to use the 'GB' option in timeconfig, not the 'London' one.
If you dual boot with windows, you'll want the "hardware clock is localtime option", otherwise use the UTC option.

Once you've got that right do a:
ntpdate ntp.virginmedia.com
or use the date command to set the time manually

And then, depending on whether your hardware clock is going to be localtime or utc, either:
hwclock -w --localtime
or
hwclock -w --utc

spoovy 08-17-2010 12:42 PM

Richard -

13.1

Code:

lrwxrwxrwx 1 root root 23 2010-08-17 16:35 /etc/localtime-copied-from -> /usr/share/zoneinfo/GMT
And yes the checksums are the same.


GazL -

I tried GB, and GMT, both give the same time (GMT -1).

I dual-boot with Ubuntu, which is set to local time I think (rather than utc)

Richard Cranium 08-17-2010 01:20 PM

Quote:

Originally Posted by spoovy (Post 4069239)
Richard -

13.1

Code:

lrwxrwxrwx 1 root root 23 2010-08-17 16:35 /etc/localtime-copied-from -> /usr/share/zoneinfo/GMT
And yes the checksums are the same.

So, that means that you've configured the system to run GMT as the local time.

Do you guys do the daylight savings time thing? If so, there is your hour difference: GMT never does DST.

spoovy 08-17-2010 04:42 PM

Yes it was showing GMT when i ran that command, as I was trying different options at the time. I had been using London time though, which I have always selected in previous linux systems I have used. I tried various different options, as in my previous post - GB, GMT, London. All the logical choices give incorrect times.

Yes we are currently on BST (British Summer Time, for which there is no setting) which is GMT+1. Are you telling me that i need to select GMT+1, then remember to change it back to GMT when BST ends? That doesn't sound right to me, that shouldn't be a manual process surely??

Richard Cranium 08-17-2010 05:10 PM

No, GB should do the right thing, but GMT would not. The GB time zone should already know about when British Summer Time starts and stops. The GMT time zone won't care.

What does the command
Code:

echo $TZ
give you? (It may give you a blank line, which is OK.) How about
Code:

date
?

spoovy 08-17-2010 05:16 PM

Yeah $TZ gives a blank line.

Date gives

Code:

Tue Aug 17 22:13:59 BST 2010

Which would be fine, but its not 22:13, it's 23:13! I notice though that it is saying BST, although there is no such option in timeconfig.

Richard Cranium 08-17-2010 05:41 PM

I assume that you have the time zone set to GB; I'm in the Central time zone, and my date command will give CDT for Central Daylight Time.

So what do you get when you issue the command
Code:

/sbin/hwclock -r && date
?

I get something like...
Code:

flacy@flacy:~$ /sbin/hwclock -r && date
Tue 17 Aug 2010 05:38:54 PM CDT  -0.687922 seconds
Tue Aug 17 17:38:54 CDT 2010

I'm just trying to see if your hardware clock and kernel time agree. If they do, then we can try to manually set them both and then you can do whatever it is that triggers the "they are now off" behavior.

spoovy 08-17-2010 05:46 PM

Code:

Tue 17 Aug 2010 10:42:57 PM BST  -0.123602 seconds
Tue Aug 17 22:42:57 BST 2010

Looks like there is a problem then?

Richard Cranium 08-17-2010 05:59 PM

No, those are the same time. (22:42:57 is 10:42:57 PM)

So, just set the kernel date with the "date" command and issue...

Code:

hwclock --set --date=`date +"%D %T"`
...to make them both the same. (The hwclock command line is untested, but should work according to the man page.)

We can test that by running the
Code:

/sbin/hwclock -r && date
command again.

spoovy 08-18-2010 01:40 PM

Richard, I think I have solved this (before reading your last post), though I don't know how it works exactly.

I dual boot with Ubuntu on this laptop and suspected this may be something to do with it. Booting into Ubuntu I found that it was set to Local, London time. I changed that to UTC, GB time. Rebooting into Slackware it is now correct, set to UTC, GB time.

Thanks for your help anyway it is much appreciated, i'm sure we would've got there in the end :)

spoov

Richard Cranium 08-18-2010 02:00 PM

No problem. Don't forget to mark the thread [SOLVED].

I suspect that if you ensure both Ubuntu and Slackware have working ntp configurations, then even if both distributions had a different idea of what was stored in the hardware clock, you would not really notice the problem. (I know Slackware starts the ntp daemon with the permission to change the clock as much as required to get it in line with the ntp server information. I'm sure Ubuntu does the same.)


All times are GMT -5. The time now is 06:03 AM.