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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
04-15-2002, 06:10 AM
|
#1
|
LQ Newbie
Registered: Feb 2001
Location: Denver, CO
Distribution: RedHat, Caldera, SuSe
Posts: 7
Rep:
|
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:
|
|
|
04-15-2002, 02:50 PM
|
#2
|
Senior Member
Registered: Nov 2001
Location: Wa. State
Distribution: Slackware
Posts: 1,261
Rep:
|
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?
|
|
|
04-15-2002, 03:20 PM
|
#3
|
LQ Newbie
Registered: Mar 2002
Posts: 1
Rep:
|
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}"
|
|
|
04-15-2002, 05:10 PM
|
#4
|
LQ Newbie
Registered: Feb 2001
Location: Denver, CO
Distribution: RedHat, Caldera, SuSe
Posts: 7
Original Poster
Rep:
|
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.
|
|
|
04-15-2002, 05:20 PM
|
#5
|
LQ Newbie
Registered: Feb 2001
Location: Denver, CO
Distribution: RedHat, Caldera, SuSe
Posts: 7
Original Poster
Rep:
|
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
|
|
|
04-15-2002, 05:49 PM
|
#6
|
LQ Newbie
Registered: Mar 2002
Location: Holland
Distribution: RH
Posts: 15
Rep:
|
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
|
|
|
08-01-2002, 04:15 AM
|
#7
|
LQ Newbie
Registered: Feb 2001
Location: Denver, CO
Distribution: RedHat, Caldera, SuSe
Posts: 7
Original Poster
Rep:
|
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.
|
|
|
05-15-2004, 04:25 PM
|
#8
|
Member
Registered: Oct 2003
Location: Florida
Distribution: Slackware
Posts: 273
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 04:38 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|