LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-15-2002, 05:10 AM   #1
warrenweiss
LQ Newbie
 
Registered: Feb 2001
Location: Denver, CO
Distribution: RedHat, Caldera, SuSe
Posts: 7

Rep: Reputation: 0
Question Setting System Time: kernel in wrong time zone


I'm having a problem setting system time. Actually, it seems that the kernel time is in UTC, while the "system" is in the correct timezone.

When I type 'date', I get the correct system time, e.g., as of this
writing:

[root@mail /root]# date
Thu Apr 11 19:48:02 MDT 2002

But, when I edit or create a file, the timestamp is 6 hours in the
future, or UTC:

[root@mail /root]# touch testfile
[root@mail /root]# ls -alF test*
-rw-rw-r-- 1 root root 0 Apr 12 01:49 testfile


My /etc/zoneinfo file points to the correct timezone file:

lrwxrwxrwx 1 root root 34 Apr 12 01:54 /etc/localtime -> /usr/sh
are/zoneinfo/America/Denver

Plus, my /etc/sysconfig/clock file seems to be set correctly:

ZONE="America/Denver"
UTC=true
ARC=false

I run a script in /etc/cron.daily to first set the system time from a
timeserver, then set the hardware clock to local time:

#!/bin/sh
#Script to set time
/usr/bin/rdate -s clock.psu.edu
/sbin/hwclock --systohc --utc

The boot file /etc/rc.d/rc.sysinit runs

/sbin/hwclock --hctosys --utc

So, any suggestions as to what I'm doing wrong or any other script that might be setting time on boot?

Thx.

:smash:
 
Old 04-15-2002, 01:50 PM   #2
taz.devil
Senior Member
 
Registered: Nov 2001
Location: Wa. State
Distribution: Slackware
Posts: 1,261

Rep: Reputation: 45
Re: Setting System Time: kernel in wrong time zone

Quote:
Originally posted by warrenweiss
My /etc/zoneinfo file points to the correct timezone file:

lrwxrwxrwx 1 root root 34 Apr 12 01:54 /etc/localtime -> /usr/sh
are/zoneinfo/America/Denver

Plus, my /etc/sysconfig/clock file seems to be set correctly:

ZONE="America/Denver"
UTC=true
ARC=false

I run a script in /etc/cron.daily to first set the system time from a
timeserver, then set the hardware clock to local time:

#!/bin/sh
#Script to set time
/usr/bin/rdate -s clock.psu.edu
/sbin/hwclock --systohc --utc

The boot file /etc/rc.d/rc.sysinit runs

/sbin/hwclock --hctosys --utc

So, any suggestions as to what I'm doing wrong or any other script that might be setting time on boot?

Thx.
I'm a tad confused myself, since you don't want to use UTC correct? Yet you seem to be using --utc option with hwclock & your sysconfig/clock file says utc=true. Could these be the problems? You may want to specify --localtime instead?
 
Old 04-15-2002, 02:20 PM   #3
ddamon
LQ Newbie
 
Registered: Mar 2002
Posts: 1

Rep: Reputation: 0
Lightbulb RE: Setting System Time: kernel in wrong time zone

warrenweiss,

You can do one of two things:

1. If your Linux server can run ntp - turn it on and point it to you time server. To do this:

NTP is off until something turns it on. The ntp daemon xntpd is one thing that turns it on. You can turn it off by running any-thing, including hwclock --hctosys, that sets the System Time the old fashioned way.
To see if it is on or off, use the command adjtimex --print and look at the value of "status". If the "64" bit of this number (expressed in binary) equal to 0, 11 minute mode is on. Otherwise, it is off.
If your system runs with NTP mode on, don't use hwclock --adjust or hwclock --hctosys. You'll just make a mess. It is acceptable to use a hwclock --hctosys at startup time to get a reasonable System Time until your system is able to set the System Time from the external source and start NTP mode.
Take out the call to your shell script in the crontab.

2. Remove /etc/adjtime if it exists. Then set the hardware clock manually by doing /sbin/hwclock --set --date="M/D/Y H:M:S" ( M=current month, D=current day, Y=current year, H=current hour, M=current minute, S=current seconds).
Edit /etc/rc.d/rc.sysinit and add /sbin/hwclock --adjust before the /sbin/hwclock --hctosys --utc.
Edit the crontab shell script to receive the time sync from your time server in a variable. Then set the hardware clock to the variable. For Example; /sbin/hwclock --set --date="${newdatetime}"
 
Old 04-15-2002, 04:10 PM   #4
warrenweiss
LQ Newbie
 
Registered: Feb 2001
Location: Denver, CO
Distribution: RedHat, Caldera, SuSe
Posts: 7

Original Poster
Rep: Reputation: 0
Re: Re: Setting System Time: kernel in wrong time zone

Quote:
Originally posted by taz.devil


I'm a tad confused myself, since you don't want to use UTC correct? Yet you seem to be using --utc option with hwclock & your sysconfig/clock file says utc=true. Could these be the problems? You may want to specify --localtime instead?
I do want to set the hardware clock to UTC, but then set the system time with the correct offset.

I originally had the hardware clock in local time and thought perhaps that that was where my problem was.
 
Old 04-15-2002, 04:20 PM   #5
warrenweiss
LQ Newbie
 
Registered: Feb 2001
Location: Denver, CO
Distribution: RedHat, Caldera, SuSe
Posts: 7

Original Poster
Rep: Reputation: 0
Re: RE: Setting System Time: kernel in wrong time zone

Quote:
Originally posted by ddamon
You can do one of two things:

1. If your Linux server can run ntp - turn it on and point it to you time server...
Use ntp instead of 'rdate', you say? OK...

Quote:

2. Remove /etc/adjtime if it exists...snip
OK, thanks for the great suggestions. I'll see what this does.

Thx
 
Old 04-15-2002, 04:49 PM   #6
nejoom
LQ Newbie
 
Registered: Mar 2002
Location: Holland
Distribution: RH
Posts: 15

Rep: Reputation: 0
If your intrested the following sets time automatically:

http://www.tinydeveloper.com/scripts/settime

if you put this in your crontab to run weekly.

on redhat just put the script in /etc/cron.weekly
 
Old 08-01-2002, 03:15 AM   #7
warrenweiss
LQ Newbie
 
Registered: Feb 2001
Location: Denver, CO
Distribution: RedHat, Caldera, SuSe
Posts: 7

Original Poster
Rep: Reputation: 0
As it turns out, the problem was with 'ls' and a few other key utilities linked to libc version 5 which, apparently, couldn't determine the correct timezone.

ldd /bin/ls
libc.so.5 => /lib/libc.so.5 (0x4000d000)

ldd /bin/date
libc.so.6 => /lib/libc.so.6 (0x4001a000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

The correct thing to do would be to fix the libc dependencies. The more correct thing to do would be to alias 'ls' to 'dir' (which works) and forget about it 'til the next OS upgrade.
 
Old 05-15-2004, 03:25 PM   #8
slackwarefan
Member
 
Registered: Oct 2003
Location: Florida
Distribution: Slackware
Posts: 273

Rep: Reputation: 30
I had the same problem, what fixed it for me was editing /etc/rc.d/rc.6 and changing the line that sets the hardwareclock
I changed it from
hwclock --localtime -syshtolc
*to*
hwclock --utc syshtolc
Worked great after that, Hope this helps someone.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get Time Zone information from the system chowdhary_g Programming 13 02-14-2018 11:15 PM
system time wrong after running cdrecord-prodvd whysyn Linux - Software 8 01-11-2005 09:19 AM
Display the date and time from another time zone lothario Linux - Software 4 07-31-2004 03:27 PM
system time is wrong, how do i change? jjd228 Linux - General 8 02-19-2004 04:12 PM
system time wrong acid_kewpie Linux - General 4 02-23-2002 09:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration