PDA

View Full Version : Updating local pc clock from a atomic clock site???



Cuddles
03-10-2004, 04:28 AM
I tried locating man pages, and info pages on the subject, I think the command was "dt" or some other package that was specifically designed for updating the pc hardware clock - my problem is that when I was looking for this information, which has hit the "back burner" because of my ALSA sound issue, I could never find the "server" to get the local time.

Does anyone, or has anyone, setup some kind of script or access, that can demonstrate the use of these packages - and can show me a list of servers to get the atomic clock time, update the local pc hardware clock, and which server I can use for my local time zone - Central Time Zone - I do honor daylight savings as well, being in Wisconsin, USA.

Thanks for any assistance in the "minor" issue,
Cuddles

windos_no_thanks
03-10-2004, 08:42 AM
To sync your local clock you can say:


ntpdate name.of.some.ntp.server

Back home I have to use:


ntpdate -u name.of.some.ntp.server

because my isp blocks the normal ports.

Google for "public ntp server" to find some server near you.

Cuddles
03-10-2004, 02:57 PM
Windos_No_Thanks,

I don't think this is working... I did a googe, and located three "secondard" sites, all of them reported to use the dns because the IP numbers can change... This is the output:

root@Polaris:/home/cuddles# ntpdate -u ntp1.cs.wisc.edu
10 Mar 07:59:34 ntpdate[8785]: sendto(128.105.39.11): Operation not permitted
10 Mar 07:59:35 ntpdate[8785]: sendto(128.105.39.11): Operation not permitted
10 Mar 07:59:36 ntpdate[8785]: sendto(128.105.39.11): Operation not permitted
10 Mar 07:59:37 ntpdate[8785]: sendto(128.105.39.11): Operation not permitted
10 Mar 07:59:38 ntpdate[8785]: no server suitable for synchronization found
root@Polaris:/home/cuddles# ntpdate ntp3.cs.wisc.edu
10 Mar 08:00:01 ntpdate[8786]: sendto(128.105.37.11): Operation not permitted
10 Mar 08:00:02 ntpdate[8786]: sendto(128.105.37.11): Operation not permitted
10 Mar 08:00:03 ntpdate[8786]: sendto(128.105.37.11): Operation not permitted
10 Mar 08:00:04 ntpdate[8786]: sendto(128.105.37.11): Operation not permitted
10 Mar 08:00:05 ntpdate[8786]: no server suitable for synchronization found
root@Polaris:/home/cuddles# ntpdate ntp3.sf-bay.org
10 Mar 08:00:22 ntpdate[8796]: sendto(206.55.70.42): Operation not permitted
10 Mar 08:00:23 ntpdate[8796]: sendto(206.55.70.42): Operation not permitted
10 Mar 08:00:24 ntpdate[8796]: sendto(206.55.70.42): Operation not permitted
10 Mar 08:00:25 ntpdate[8796]: sendto(206.55.70.42): Operation not permitted
10 Mar 08:00:26 ntpdate[8796]: no server suitable for synchronization found

All three sites come up with the same error, with or without the "-u" - I also have ntp set in my firewall for access. Am I missing something? (again?)

Thanks,
Cuddles

Cuddles
03-10-2004, 03:11 PM
OOPS -=- spoke too soon, I didn't have ntp set in my firewall, unfortunately, when I ran the servers (which are local based here in Wisconsin) - it threw my clock off by +7 hours - do I need to supply some sort of GMT variable? (because I think that is exactly what my "offset" is)

Now that my hardware clock thinks its 3:10 PM, when it actually should be 8:10 AM - I can poke the time change, but I was looking for a quick shell script to run this under to update the clock...

Thanks for any help,
Cuddles

Cuddles
03-10-2004, 04:08 PM
More information needed...

I setup a nice shell script to enter all the info of the ntpdate command, currently got it now to within one hour ahead of my time - so I am getting closer - my STATE isn't even on the list, let alone a city (for setting my time zone) I am currently set to Thunder Bay - which I would guess, is one hour ahead of me...

Problem is that if I run the shell script from a user other than root, I get the message "you are not in the sudoers file, this incident will be reported" - I have the "sudo" infront of the command in the script.

I already added my users into the sudoers file, with the "proper" use of visudo - but it doesn't appear to be loading the changes I made. What gives?

ALSO, how can I make my script shell command "local" to a standard command, like kwrite or something???

I know, why does everything I do require six posts, and problems, I don't know, I guess I am just "lucky" I guess???

Thanks ahead of time,
Cuddles

Cuddles
03-10-2004, 04:43 PM
I'm starting to get the hang of this, sooner, or later...

Figured out what a mucked up in the sudoers file, and now my "users" can run as sudo - now...

So, I guess the only thing I still need to know, is, how can I get a shell script in a location that any of my "sudo" users can run my shell script that I have made to time adjust through ntpdate???

BTW - I found a time zone that worked - It was a city that - I guess - borders Wisconsin and another state - but the result is that the city is in my time zone - heck of a lot better than London and Los Angels, and a whole slew of other time zones that were set by default in the clock - time zone - settings...

Give a girl enough rope, and she just might find another way to hang herself - or in this case - give a girl enough time, and she might just find the answer on her own [giggle]
Cuddles

Markus
03-10-2004, 09:26 PM
You can just run it at startup without the need to sudo.
Here's a nice short how-to:
http://www.desktop-linux.net/debian-rclocal.htm

EDIT: This would though need a cable or ADLS connection :(

Cuddles
03-11-2004, 12:43 AM
Markus,

Sorry to say, nope, dial-up connection only - so the auto-start on boot time adjust isn't going to work...

So, the querry still stands, how and where do I place a shell script that can be accessed by any user. Permissions have already been set for all my users to run the script, and sudo has been enabled on these users as well...

Cuddles

windos_no_thanks
03-11-2004, 09:47 AM
So, the querry still stands, how and where do I place a shell script that can be accessed by any user. Permissions have already been set for all my users to run the script, and sudo has been enabled on these users as well...

Umm, you could just put it in root's crontab instead and perhaps add something in the beginning of it so that it aborts if it doesn't have network connectivity.

Dave_Bechtel
03-14-2004, 01:48 AM
--First of all, you should run ' /usr/sbin/tzconfig ' and set your local timezone.

--The ONLY person who should be updating the machine's clock, is ROOT. Don't give out sudo permissions to just anyone - restrict it to maybe 1-2 other people at the most.

--Here is a copy of the script I use; you should be OK with running the script about once a month. Unless your CMOS battery is dying or something, you really --don't-- need to sync the time all that often.

BEGIN /root/bin/timesync


#!/bin/sh

date
ntpdate -s pool.ntp.org
date

#ntp1.linuxmedialabs.com
# pool.ntp.org
# ntp1.tummy.com - CO
# louie.udel.edu - DElwr
# ntp.shorty.com - GA

# inetd's timeserver is port 37; use ' rdate p233 '


--Once you have your "master server's" time set, you can edit its /etc/inetd.conf and uncomment the following lines:



daytime stream tcp nowait root internal
daytime dgram udp wait root internal
time stream tcp nowait root internal
time dgram udp wait root internal


--Then, if you need to, ' /etc/init.d/inetd start ' on the server as root. This should shed some light on the comment at the end of the above script; if you have inetd running with those services, you can go to another computer on the network (running Linux of course) and just ' rdate insert-name-of-internet-connected-box-here '. You may have to ' apt-get install rdate ' on the client(s); I forget if it comes on the live-cd.

--The nice thing about this is that only the master server needs to be updated via ntp; the other clients can then set their time from it using rdate.

--However, I wouldn't leave inetd running unless you have to; it opens up ports. I only start it when I need it, personally.

--Best wishes.


Markus,

Sorry to say, nope, dial-up connection only - so the auto-start on boot time adjust isn't going to work...

So, the querry still stands, how and where do I place a shell script that can be accessed by any user. Permissions have already been set for all my users to run the script, and sudo has been enabled on these users as well...

Cuddles

lothario
03-15-2004, 03:11 AM
As root, I changed the time zone with tzconfig to PST.
But the change cannot be saved because KNOPPIX tells
me that /etc/timezone is on the READ-ONLY filesystem.

As long as my system is running my time zone stays at PST.
But after a reboot, it goes back to the CET time zone.
(And I have to update the time zone again.)

How do I make the PST time zone permanent?

Dave_Bechtel
03-15-2004, 06:39 AM
--Since you are running from the live-cd, you can do this:

' la /etc/timezone ' == List it

' cd /etc '
' rm timezone ' == Remove symlink
' cp /KNOPPIX/etc/timezone . ' == Copy original file over

' tzconfig ' == Change timezone

--I haven't tested it with persistent home, but it *should* keep the changes if you update your saved-config.


As root, I changed the time zone with tzconfig to PST.
But the change cannot be saved because KNOPPIX tells
me that /etc/timezone is on the READ-ONLY filesystem.

As long as my system is running my time zone stays at PST.
But after a reboot, it goes back to the CET time zone.
(And I have to update the time zone again.)

How do I make the PST time zone permanent?

grante
04-02-2004, 01:07 AM
--Since you are running from the live-cd, you can do this:

' la /etc/timezone ' == List it
' cd /etc '
' rm timezone ' == Remove symlink
' cp /KNOPPIX/etc/timezone . ' == Copy original file over
' tzconfig ' == Change timezone

--I haven't tested it with persistent home, but it *should* keep the changes if you update your saved-config.

That does change /etc/timezone and preserve it across reboots, but it doesn't seem to effect anything. I performed the change above, did a save-config, rebooted, and here's what I get:

root@0[knoppix]# cat /etc/timezone
US/Central
root@0[knoppix]# /usr/sbin/tzconfig
Your current time zone is set to US/Central
Do you want to change that? [n]: n
Your time zone will not be changed
root@0[knoppix]# date
Thu Apr 1 18:51:12 EST 2004

Notice that 'date' is still displaying EST (so does 'ls', the desktop clock, and everything else I've tried).

Since changing /etc/timezone doesn't seem to change the timezone, what does?

lothario
04-02-2004, 08:03 AM
I agree with grante.
I experienced the same thing.

I have the same question:
Since changing /etc/timezone doesn't seem to change the timezone, what does?

Markus
04-02-2004, 08:42 AM
Have a look at the symlink /etc/localtime and see where it points to. If it's incorrect delete it and make a new one with:
ln -s /usr/share/zoneinfo/whereeveryouare /etc/localtime

Dave_Bechtel
04-03-2004, 08:33 AM
--Also have a look at /etc/init.d/hwclock.sh ; you might try running it again as root after updating the time, altho I haven't tested this.


Have a look at the symlink /etc/localtime and see where it points to. If it's incorrect delete it and make a new one with:
ln -s /usr/share/zoneinfo/whereeveryouare /etc/localtime