Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
hwclock --utc == local time, --localtime == UTC time?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
pachanga
Tux's lil' helper
Tux's lil' helper


Joined: 03 Dec 2004
Posts: 123
Location: Russia, Penza

PostPosted: Thu Jul 28, 2005 11:20 am    Post subject: hwclock --utc == local time, --localtime == UTC time? Reply with quote

Guys i'm a bit confused with results of querying hwclock.

My local time is GMT + 4, so first i set my system time using "date". Then i set hwclock using "hwclock --systohc --utc" command in order to have my RTC in UTC. However querying hwclock reveals a bit confusing results:

Code:

# hwclock --utc
Thu Jul 28 15:14:13 2005  -0.530722 seconds


Code:

# hwclock --localtime
Thu Jul 28 11:14:40 2005  -0.476347 seconds


It seems it prints local time with --utc switch and its actual internal time with --localtime switch, right? If yes, why not vice versa? It would be more logical IMHO...


Last edited by pachanga on Fri Jul 29, 2005 8:19 am; edited 2 times in total
Back to top
View user's profile Send private message
RiBBiT
Apprentice
Apprentice


Joined: 18 May 2005
Posts: 215
Location: Sweden

PostPosted: Thu Jul 28, 2005 11:25 am    Post subject: Reply with quote

For me it's the other way around.
_________________
Comix - GTK Comic Book Viewer [ http://comix.sourceforge.net ]
Back to top
View user's profile Send private message
pachanga
Tux's lil' helper
Tux's lil' helper


Joined: 03 Dec 2004
Posts: 123
Location: Russia, Penza

PostPosted: Thu Jul 28, 2005 11:27 am    Post subject: Reply with quote

RiBBiT wrote:
For me it's the other way around.


Do you mean running hwclock --utc returns UTC time?
Back to top
View user's profile Send private message
RiBBiT
Apprentice
Apprentice


Joined: 18 May 2005
Posts: 215
Location: Sweden

PostPosted: Fri Jul 29, 2005 12:32 am    Post subject: Reply with quote

That's exactly what I meant. However I just discovered I was wrong, my hardware clock had been f*cked up by my Windows installation so it was set to local time. hwclock --utc indeed seems to display the local time while hwclock --localtime displays UTC, weird.
_________________
Comix - GTK Comic Book Viewer [ http://comix.sourceforge.net ]
Back to top
View user's profile Send private message
irasnyd
Apprentice
Apprentice


Joined: 16 Feb 2003
Posts: 286
Location: Placentia, CA

PostPosted: Fri Jul 29, 2005 5:53 am    Post subject: Reply with quote

Same thing is happening here. I haven't had windows on this machine in almost a year.

Code:

yuki ~ # date
Thu Jul 28 22:47:01 PDT 2005

yuki ~ # hwclock --utc
Thu Jul 28 22:47:08 2005  -0.287794 seconds

yuki ~ # hwclock --localtime
Fri Jul 29 05:47:14 2005  -0.328052 seconds

yuki ~ # ls -l /etc/localtime
lrwxrwxrwx  1 root root 39 Feb 18 16:51 /etc/localtime -> /usr/share/zoneinfo/America/Los_Angeles

yuki ~ # hwclock -w --utc

yuki ~ # hwclock --utc
Thu Jul 28 22:48:18 2005  -0.997177 seconds

yuki ~ # hwclock --localtime
Fri Jul 29 05:48:22 2005  -0.397110 seconds


And here is my /etc/conf.d/clock file:
Code:

# /etc/conf.d/clock

# Set CLOCK to "UTC" if your system clock is set to UTC (also known as
# Greenwich Mean Time).  If your clock is set to the local time, then
# set CLOCK to "local".

CLOCK="UTC"

# If you wish to pass any other arguments to hwclock during bootup,
# you may do so here.

CLOCK_OPTS=""

# If you want to set the Hardware Clock to the current System Time
# during shutdown, then say "yes" here.

CLOCK_SYSTOHC="yes"


### ALPHA SPECIFIC OPTIONS ###

# If your alpha uses the SRM console, set this to "yes".
SRM="no"

# If your alpha uses the ARC console, set this to "yes".
ARC="no"


How did you get it fixed? I can't seem to get my clock set to UTC. I thought it was for all this time. "date" has been working fine, although I have been seeing some weird times in my logs. Maybe this is related.

Thanks.
Back to top
View user's profile Send private message
pachanga
Tux's lil' helper
Tux's lil' helper


Joined: 03 Dec 2004
Posts: 123
Location: Russia, Penza

PostPosted: Fri Jul 29, 2005 8:16 am    Post subject: Reply with quote

irasnyd wrote:

How did you get it fixed? I can't seem to get my clock set to UTC.


If you're talking about RTC, try

Code:

hwclock --systohc --utc


This should set your hardware clock equal to system clock and mark it as UTC time.
Back to top
View user's profile Send private message
pachanga
Tux's lil' helper
Tux's lil' helper


Joined: 03 Dec 2004
Posts: 123
Location: Russia, Penza

PostPosted: Fri Jul 29, 2005 8:18 am    Post subject: Reply with quote

RiBBiT wrote:
hwclock --utc indeed seems to display the local time while hwclock --localtime displays UTC, weird.


Maybe that's ok? Well i can live with that but they should point this issue more explicitly in man then IMHO...
Back to top
View user's profile Send private message
Kaapeli
Tux's lil' helper
Tux's lil' helper


Joined: 27 Dec 2004
Posts: 110
Location: Oulu, Finland

PostPosted: Fri Jul 29, 2005 2:50 pm    Post subject: Reply with quote

pachanga wrote:
irasnyd wrote:

How did you get it fixed? I can't seem to get my clock set to UTC.


If you're talking about RTC, try

Code:

hwclock --systohc --utc


This should set your hardware clock equal to system clock and mark it as UTC time.


Doesn't this do it automatically correctly:

Code:

/etc/init.d/clock save

_________________
Temperatures
Back to top
View user's profile Send private message
pachanga
Tux's lil' helper
Tux's lil' helper


Joined: 03 Dec 2004
Posts: 123
Location: Russia, Penza

PostPosted: Fri Jul 29, 2005 3:08 pm    Post subject: Reply with quote

Well, anyway the question remains - is this behaviour of hwclock ok???
Back to top
View user's profile Send private message
RiBBiT
Apprentice
Apprentice


Joined: 18 May 2005
Posts: 215
Location: Sweden

PostPosted: Sat Jul 30, 2005 11:08 am    Post subject: Reply with quote

I think I discovered why it seems wrong. hwclock ALWAYS displays the local time. --utc tells hwclock it is set by UTC and the timezone modifier is applied to the time before it is displayed. If --localtime is used hwclock thinks it is already synced with local time and the timezone modifier is not applied.
_________________
Comix - GTK Comic Book Viewer [ http://comix.sourceforge.net ]
Back to top
View user's profile Send private message
pachanga
Tux's lil' helper
Tux's lil' helper


Joined: 03 Dec 2004
Posts: 123
Location: Russia, Penza

PostPosted: Sat Jul 30, 2005 11:21 am    Post subject: Reply with quote

RiBBiT wrote:
I think I discovered why it seems wrong. hwclock ALWAYS displays the local time. --utc tells hwclock it is set by UTC and the timezone modifier is applied to the time before it is displayed. If --localtime is used hwclock thinks it is already synced with local time and the timezone modifier is not applied.


Still pretty weird, isn't it?
Back to top
View user's profile Send private message
RiBBiT
Apprentice
Apprentice


Joined: 18 May 2005
Posts: 215
Location: Sweden

PostPosted: Sat Jul 30, 2005 11:50 am    Post subject: Reply with quote

pachanga wrote:
RiBBiT wrote:
I think I discovered why it seems wrong. hwclock ALWAYS displays the local time. --utc tells hwclock it is set by UTC and the timezone modifier is applied to the time before it is displayed. If --localtime is used hwclock thinks it is already synced with local time and the timezone modifier is not applied.


Still pretty weird, isn't it?


Not very weird when you think about it. hwclock have no means to know if it set by UTC or local time by it self, so asking it to display the time of the current system (which is always local time) makes no sense if you don't tell it what timezone it is set by in the first place.
_________________
Comix - GTK Comic Book Viewer [ http://comix.sourceforge.net ]
Back to top
View user's profile Send private message
CarlosAB
n00b
n00b


Joined: 04 Apr 2005
Posts: 8
Location: Brazil-RS

PostPosted: Sat Aug 06, 2005 2:56 pm    Post subject: Dazed & confused Reply with quote

So, how can someone like me can setup his RTC and system clock, with "/etc/init.d/clock" and his step brother "/etc/conf.d/clock", to work togheter as a team.

Thanks

Carlos[/code]
Back to top
View user's profile Send private message
firekopf
n00b
n00b


Joined: 30 Nov 2004
Posts: 31

PostPosted: Sat Aug 06, 2005 4:48 pm    Post subject: Reply with quote

okay, I'm having a similar problem with my hwclock. Whenever I type hwclock it says it 'timed out waiting for time change' so the hwclock is not set, meaning it defaults to January 1, 1970 for some reason. I can change the software clock with date but I don't want to have to do that every boot.

Anyone have a solution?
Back to top
View user's profile Send private message
RiBBiT
Apprentice
Apprentice


Joined: 18 May 2005
Posts: 215
Location: Sweden

PostPosted: Sat Aug 06, 2005 5:19 pm    Post subject: Reply with quote

firekopf wrote:
okay, I'm having a similar problem with my hwclock. Whenever I type hwclock it says it 'timed out waiting for time change' so the hwclock is not set, meaning it defaults to January 1, 1970 for some reason. I can change the software clock with date but I don't want to have to do that every boot.

Anyone have a solution?


Could it be your BIOS battery that's running low? The reason your hardware clock is set to January 1, 1970 is because that is the base of most computer clocks. The current time is expressed as a number of seconds from January 1, 1970. 19:15:34 today, for an example, is 1123348534 seconds from January 1, 1970. If you don't want to change the clock manually every boot you can use some NTP application (emerge ntp).
_________________
Comix - GTK Comic Book Viewer [ http://comix.sourceforge.net ]
Back to top
View user's profile Send private message
firekopf
n00b
n00b


Joined: 30 Nov 2004
Posts: 31

PostPosted: Sat Aug 06, 2005 7:15 pm    Post subject: Reply with quote

I'm not sure the actual physical hardware clock is the problem. Wouldn't it still be able to detect a tick when it had main power? The clock on my Mac OS partition functions fine, which I don't think it would if the actual clock ran out of juice.
Back to top
View user's profile Send private message
RiBBiT
Apprentice
Apprentice


Joined: 18 May 2005
Posts: 215
Location: Sweden

PostPosted: Sat Aug 06, 2005 7:38 pm    Post subject: Reply with quote

Do you have clock set up to start at boot (rc-update show)? Can you post your /etc/conf.d/clock?
_________________
Comix - GTK Comic Book Viewer [ http://comix.sourceforge.net ]
Back to top
View user's profile Send private message
firekopf
n00b
n00b


Joined: 30 Nov 2004
Posts: 31

PostPosted: Mon Aug 08, 2005 3:32 pm    Post subject: Reply with quote

just out of curiosity, its probably a bad sign that I don't have /etc/conf.d/clock?
Back to top
View user's profile Send private message
theWebster
n00b
n00b


Joined: 26 Nov 2003
Posts: 4
Location: 15 min south of KU

PostPosted: Sat Aug 27, 2005 5:10 am    Post subject: Reply with quote

arrgh!! I think I finally got this working, but I'm confused by the redundancies I see and have yet
to check what happens if I try setting the time in KDE (not that I should *ever* have to do so again...!!!)
Anyhow, my hwclock, date and localtime all reported UTC time. I checked that /etc/timezone was set OK,
but had failed to notice that somewhere along the way the /etc/localtime had VANISHED. So, after
Code:
ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime
it is looking fixed.

I'm using
Code:
emerge ntp


Code:
# /etc/conf.d/ntp-client

NTPCLIENT_CMD="ntpdate"
NTPCLIENT_OPTS=" -b -u 0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org"
NTPCLIENT_TIMEOUT=30


Code:
# /etc/conf.d/clock
CLOCK="local"
CLOCK_OPTS=""
CLOCK_SYSTOHC="no"
SRM="no"
ARC="no"


Code:
# /etc/conf.d/ntpd
NTPD_OPTS="-u ntp:ntp"


HTH, it has been about the most irritating item so far, but I've been away for several years as the weeks
it took to get as far as a CLI was too frustrating. I have however, in two days, got through wiping all I had
before and installing fresh from Stage 3 tarball and minimal CD, to an incredibly awesome dazzling KDE
complete with a dozen or two goodies beyond the default base, including koffice, samba and support for
my nForce ethernet (that last being #2 irritation...) I am feeling about the same as when I first succeeded
in creating a PPP connection and fired up the then-brand-new Netscape. I believe gentoo will save mankind, I do.
_________________
michael
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum