ntp time server select ?


Forum: Other Help Topics
Topic: ntp time server select ?
started by: bjhbjh

Posted by bjhbjh on Feb. 28 2008,01:49
Running the latest DSL. Have found how to set the time via an ntp server and it all works but don't see how I can set which time server to use, or even know which one it uses by default. Can I point it to the time server of my choice some how?

Thanks,

Brian H.

Posted by roberts on Feb. 28 2008,05:48
Built into DSL is a script to set time using NIST see: < http://tf.nist.gov/service/its.htm >

Looking at that script /usr/local/bin/gettime.lua you will see that it uses a default its of time-nw.nist.gov

The script also accepts a runtime paramter such that you can overridde the default with an internet time server near you.

sudo gettime.lua your_its_server_here

If your internet connection is up and available upon boot then add the command to your /opt/bootlocal.sh.  sudo not needed as bootlocal.sh is run as root upon booting.

Posted by Juanito on Feb. 28 2008,16:39
Would it be possible to modify the gettime script to accept a user input of the form "GMT+-n"?

The reason I ask is that (as far as I know) my time zone is not one of the choices available in dsl and, since my time stays the same all year (i.e. there is no daylight savings adjustment), I was thinking it might be possible to say something like:

$ sudo gettime.lua GMT+4

and have my machine's clock adjusted correctly

Posted by curaga on Feb. 28 2008,16:53
NIST gives the UTC time. Doesn't DSL recognize the GMT+? timezones?

I mean, if you have the clock in UTC, linux can set the local time according to that.

Posted by Juanito on Feb. 28 2008,17:16
Quote
Doesn't DSL recognize the GMT+? timezones?

- no

Quote
I mean, if you have the clock in UTC, linux can set the local time according to that

- I'm not sure if I caught the right meaning here, but if the clock is in UTC, you need to have the means to pass a time offset (i.e. tell the system where you are). At the moment, if  I enter nothing and then run gettime.lua, the clock is set to GMT-4 (dsl default of US east coast I guess)

Posted by curaga on Feb. 28 2008,18:39
Are you sure no included timezones match yours?
Posted by Juanito on Feb. 28 2008,19:32
Quote
Are you sure no included timezones match yours?

- Moscow matches some of the year, but not at the moment...

Posted by curaga on Feb. 28 2008,19:40
Why not remaster then with your file?
Posted by bjhbjh on Feb. 28 2008,20:05
Quote
Built into DSL is a script to set time using NIST see: < http://tf.nist.gov/service/its.htm >

Looking at that script /usr/local/bin/gettime.lua you will see that it uses a default its of time-nw.nist.gov


Ok thats cool, thanks.

I could have figured this out myself I guess if I could have seen what the that the Setup/Date&Time/ViaInternetTimeServer menu item was linked to. In MS win its just a right click and properties but I can't do that here, or can I?

Is there a way to see what the DSL menu items are linked to ?

Thanks,

Brian H.

Posted by lucky13 on Feb. 28 2008,21:43
Quote
Is there a way to see what the DSL menu items are linked to ?

The JWM menu is in .jwmrc. It's just an XML file.

Posted by Juanito on Mar. 01 2008,18:07
Quote
Why not remaster then with your file?

- I tried copying the time file for GMT+4 to /opt and renaming it "localtime", then:
Code Sample
$ sudo gettime.lua
Requesting time from: time-nw.nist.gov
Sat Mar  1 17:59:50 UTC 2008

At 21:59 local time, this set the clock to 00:59pm - not being used to this am/pm stuff, I'm not totally sure whether that means 12:59 or 00:59. Anyway, it isn't 21:59...

Posted by ^thehatsrule^ on Mar. 01 2008,18:46
Afaik, am/pm does not have 00: and only 12:
so something could be wrong...?

Posted by roberts on Mar. 01 2008,18:53
DSL uses zoneinfo files.
You can find a complete list < here/ >

DSL also has zump and zic needed to process/setup zoneinfo files.

Download tzdata2007k.tar.gz to a working directory, unpack,  and then use zic  to convert to a format Linux/DSL uses.

You can "grep -i" to search for your location in the various regions (after you have unpacked them).
Once you use zic they will no longer be readable.

HTH



Posted by curaga on Mar. 01 2008,20:04
isn't localtime supposed to be in /etc by the way?
Posted by Juanito on Mar. 02 2008,09:42
Quote
Afaik, am/pm does not have 00: and only 12:
so something could be wrong...?

- it actually said a couple of minutes later - 01:01pm - so the mistake was made by me subtracting a couple of minutes to "avoid confusion".

Quote
isn't localtime supposed to be in /etc by the way?

- well:

/usr/share/zoneinfo/localtime -> /etc/localtime
and
/etc/timezone -> /KNOPPIX/etc/timezone -> /opt/timezone

...so I wasn't sure which one to use. I guess /opt/timezone uses the bootcode? Which one should I add to my backup (assuming I ever get this to work)?

Quote
DSL uses zoneinfo files.
You can find a complete list here/

DSL also has zump and zic needed to process/setup zoneinfo files.

Download tzdata2007k.tar.gz to a working directory, unpack,  and then use zic  to convert to a format Linux/DSL uses.

You can "grep -i" to search for your location in the various regions (after you have unpacked them).
Once you use zic they will no longer be readable.

- I thought GMT+4 was a zoneinfo file, it is included in the latest tzdata2007k.tar.gz file from your link (thanks BTW). Also from tzdata2007k.tar.gz:
Quote
# We use POSIX-style signs in the Zone names and the output abbreviations,
# even though this is the opposite of what many people expect.
# POSIX has positive signs west of Greenwich, but many people expect
# positive signs east of Greenwich.  For example, TZ='Etc/GMT+4' uses
# the abbreviation "GMT+4" and corresponds to 4 hours behind UTC
# (i.e. west of Greenwich) even though many people would expect it to
# mean 4 hours ahead of UTC (i.e. east of Greenwich).

- which explains some of my confusion...

I tried zic and zdump, but didn't get the hang of the syntax yet:
Code Sample
$ sudo zic -l asia/placename

...doesn't seem to write the localtime file for "placename" and using only asia gives the whole nine yards in localtime and still in a readable format??

Posted by roberts on Mar. 02 2008,18:04
For others who might be reading this thread, all of the supported locations are in /usr/share/zoneinfo. If your particular location is not supported then...

1. Make a working directory
   mkdir tzdata
2. Change to it
   cd tzdata
3.  Get the latest zoneinfo data files
   wget < ftp://elsie.nci.nih.gov/pub/tzdata2007k.tar.gz >
4.  Unpack it
    tar -zxvf tzdata2007k.tar.gz
5. Find your major area
   ls -l
6. Compile for your location, eg, asia
   zic -d zoneinfo asia
7. Find your specific area
   ls -l zoneinfo
8  Copy the newly created zoneinfo file, e.g.,
   sudo zoneinfo/Asia/Saigon /usr/share/zoneinfo/Asia/.

   or to /etc/localtime


HTH

Posted by ^thehatsrule^ on Mar. 02 2008,19:21
Well if it does point to the one in opt, imo that's probably the best one to choose (along with bootlocal, etc.)
Posted by Juanito on Mar. 03 2008,14:11
I tried this in dsl-3.4.11:
Code Sample
$ sudo mkdir /tmp/tzdata
$ sudo chown dsl /tmp/tzdata
$ sudo chgrp staff /tmp/tzdata
$ cd /tmp/tzdata
$ tar -zxvf tzdata2007k.tar.gz
$ zic -d zoneinfo asia
$ sudo cp zoneinfo/Asia/Dubai /usr/share/zoneinfo/Asia/
$ sudo rm /etc/localtime
$ sudo cp zoneinfo/Asia/Dubai /etc/localtime
$ sudo gettime.lua
Requesting time from: time-nw.nist.gov
Mon Mar  3 14:06:10 UTC 2008


The UTC is correct but the time in the menu bar thing is not updated??

Posted by roberts on Mar. 03 2008,15:56
Normally gettime.lua as well as setting localtime is done during the boot process and not from within X-windows.

If one runs the process from within X then restart your window manager to see the results of time in your taskbar.

Posted by WDef on Mar. 05 2008,22:41
zdump on dsl always seems to give me the wrong time for any location I try, whether listed in /usr/share/zoneinfo or not?  Unless I'm missing something.

This is one reason I wrote my citytime thing.

Posted by Juanito on Mar. 07 2008,10:16
Quote
If one runs the process from within X then restart your window manager to see the results of time in your taskbar.

- that did it, thanks for the help.

The following were added to my backup:

usr/share/zoneinfo/Asia/Dubai
etc/localtime

...though I guess only etc/localtime is required.

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.