LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Slackware 13.37 - XFCE - How to set the time (http://www.linuxquestions.org/questions/slackware-14/slackware-13-37-xfce-how-to-set-the-time-935548/)

jdgr 03-20-2012 03:47 PM

Slackware 13.37 - XFCE - How to set the time
 
Hi all,

I'm looking to change my time on my Slackware 13.37 XFCE system. It is about 5 minutes faster than my work clocks so I need to modify it (or link it to a proper time server).

This seems like such a trivial thing to do but I am unable to figure out how to do it, and I can't find anything online. I found 1 ubuntu command and tried it for the hell of it, but it was not found (don't quite remember, I think it was tzconfig or something like that).

Anyone know how to set the time?

Thanks.

camorri 03-20-2012 04:16 PM

This link covers setting the clock, and setting up ntpd daemon.

-->http://humanreadable.nfshost.com/sdeg/ntpd.htm

Hope this helps.

KeithE 03-20-2012 05:38 PM

The netdate program works well
 
Calling /usr/sbin/netdate with an NIST server address as the parameter works very well. I put a script called setdate in my cron.daily folder to set the system clock once per day (that's plenty for my system). This script includes the following:

Code:

#!/bin/sh

# $NameOfServer is the desired NIST time server.
/usr/sbin/netdate $NameOfServer

AFAIK, only Slackware includes this program, but I have had success installing it on other distros. Be sure to make it executable, of course.

List of NIST timer servers

allend 03-20-2012 07:04 PM

On my netbook I have these lines active in my /etc/ntp.conf
Quote:

fudge 127.127.1.0 stratum 10
server au.pool.ntp.org #My time server choice
driftfile /etc/ntp/drift
restrict default noquery nomodify
restrict 127.0.0.1
To update the time, when I have an internet connection, in a terminal I run
Code:

su -c 'ntpd -q'
As I understand it, ntpdate is deprecated and 'ntpd -q' should be used instead.

GazL 03-21-2012 05:22 AM

Quote:

Originally Posted by allend (Post 4632049)
To update the time, when I have an internet connection, in a terminal I run
Code:

su -c 'ntpd -q'
As I understand it, ntpdate is deprecated and 'ntpd -q' should be used instead.

That's my understanding too, however, I've never managed to get 'ntpd -q' to work for me. Here's an example

Code:

root@slackbox:~# date
Wed Mar 21 10:15:37 GMT 2012
root@slackbox:~# ntpd -g -q
ntpd: time slew +0.000000s
root@slackbox:~# date
Wed Mar 21 10:15:50 GMT 2012
root@slackbox:~# ntpdate pool.ntp.org
21 Mar 10:15:59 ntpdate[2384]: step time server 89.188.26.129 offset -13.480052 sec
root@slackbox:~#

As you can see ntpd -q doesn't adjust the time but ntpdate does. Really not sure what is going on here.

jdgr 03-21-2012 06:55 AM

Wow, lots of answers. I guess it's a rather simply (although complex) problem that has come up numerous times. I will read the tutorial and try what you are all suggesting when I have a free minute (I am at work and its my work laptop, time kind of takes a back seat to incoming tickets). I'll let you know how it goes.

allend 03-21-2012 10:34 AM

Quote:

I've never managed to get 'ntpd -q' to work for me
It has been a while, but I think the trick is in the 'restrict' options as well as deactivating any multicastclient lines in ntp.conf.

aocab 03-21-2012 11:00 AM

Quote:

Originally Posted by GazL (Post 4632380)
That's my understanding too, however, I've never managed to get 'ntpd -q' to work for me. Here's an example

Code:

root@slackbox:~# date
Wed Mar 21 10:15:37 GMT 2012
root@slackbox:~# ntpd -g -q
ntpd: time slew +0.000000s
root@slackbox:~# date
Wed Mar 21 10:15:50 GMT 2012
root@slackbox:~# ntpdate pool.ntp.org
21 Mar 10:15:59 ntpdate[2384]: step time server 89.188.26.129 offset -13.480052 sec
root@slackbox:~#

As you can see ntpd -q doesn't adjust the time but ntpdate does. Really not sure what is going on here.

Same here until I commented out the local clock server in ntp.conf.
my /etc/ntp.conf
Code:

server us.pool.ntp.org
set the clock back a few minutes
Code:

date
Wed Mar 21 10:55:50 CDT 2012

date --set="21 MAR 2012 10:53:00"
Wed Mar 21 10:53:00 CDT 2012

ntpd -qg
ntpd: time set +185.737199s

date
Wed Mar 21 10:56:19 CDT 2012

HTH

GazL 03-21-2012 02:09 PM

Thanks for that aocab And yes, it does the same here. Now I'm wondering whether that's a bug or a feature. :)

jdgr 03-22-2012 08:55 AM

Since setting up the sync with a time server is much more then I required on my work laptop at this time, I just used the hwclock program to set my clock. Didn't know about this program until I read the article camorri posted. Thanks very much for all your answers everyone.

interndan 03-22-2012 10:54 AM

I don't recall where I found this, but the simplest solution I have found is create a file in /etc/cron.daily I named it settime.
Code:

/usr/sbin/ntpdate north-america.pool.ntp.org && /sbin/hwclock -w
make the file executable (chmod +x) and everytime you start your computer it sets the hardware clock to the correct time. Change the time server to one appropriate for you location. If you need to update more frequently it will also work in cron.hourly.

Dan

jdgr 03-22-2012 01:25 PM

Thanks for that interndan. I'm going to try that out and see how it goes. I don't know if I have to worry too much about my clock changing it's time on reboot, it's just the time was about 6 minutes off when I installed Slackware. But I'll see on next reboot and give this a shot.

interndan 03-22-2012 01:32 PM

If you don't want to reboot after you create the file, just issue (as root) /etc/cron.daily/settime.

zarglink 10-20-2012 02:03 PM

security issues with time servers
 
as part of the response to global craziness in response to a recommendation by homeland security my company has suggested that no critical systems use an external time server to set their times automagically since it is believed that a first strike cyber attack could of course involve invoking chaos through alteration of system times on the target network.

in response to the observation that 'the critical systems are the only ones that NEED to be synchronized" we've set up an internal time server which is manually updated as needed.

silliness i know, no pun intended but these are the times we live in.

i am particularly wary of anything that updates my time to an external source anyway since despite assurances that it will all be fine, i have at least one device a year fail to get the right time during day light savings changes. that's when the key-wound chronometer alarm gets used for a few days :)

tronayne 10-21-2012 10:09 AM

If you're going to run the NTPD daemon, syncing to a network time service referenced to NIST, it's a good idea to set up your /etc/ntp.conf server section like this:
Code:

server        127.127.1.0        # local clock
fudge        127.127.1.0 stratum 10       
#server  pool.ntp.org
server  0.us.pool.ntp.org
server  1.us.pool.ntp.org
server  2.us.pool.ntp.org

Directly above this section in the file is an explanation of why the local clock entry is used (so when there's no external time source available the daemon can fall back on it until an outside source does become available).

You really do not need to edit anything else in that file to get NTP going -- you may want to tweak later for some reason but it's good to go as delivered in Slackware.

Three entries for pool servers provides a way for the daemon to synchronize to the best of three; you really don't need more than three.

This peculiar form of the entries -- 0.us.pool.ntp.org -- is a hangover from a problem that cropped up some years ago in NTP where a simple pool.ntp.org didn't work properly and adding the leading digits (0, 1, 2) solved the problem and it still works OK, so what the heck. Ain't necessary but I just leave it that way; YMMV.

The "us" part restricts the pool to US-based servers. You can use the country code for wherever you are in the world (where, hopefully, there are at least three servers electrically close and clean).

It's not a good idea (or practice, for that matter) to directly use stratum one servers -- those are the atomic clocks -- which are reserved for "large" stratum two servers to synchronize to. The stratum two servers are the ones you want to sync with and those are the pool servers. You can sync with a stratum one server but you're supposed to notify them and get permission from the administrator to do so (if they get too much traffic they won't be happy campers).

It's also a good idea to set your hardware clock to UTC and set you locale to whatever time zone you're in so that your clock display is local time (with the automagic switch to and from daylight time).

It's a good idea if your hardware clock is not within a few seconds of actual time to set it once before you start NTP. You can do that as described in earlier posts in this thread. Once NTP is running you'll stay in sync and you won't need to do a manual or cron clock setting; most system clocks don't drift enough if the system is powered down overnight to need a manual setting; of course, if your clock battery is dead, that won't be true but generally takes a few years for that battery to go flat.

When you first boot the system (and have /etc/rc.d/rc.ntpd executable) it will take a few minutes for NTP to sync up with a server; wait about 10 minutes and
Code:

/usr/sbin/ntpq -p
    remote          refid      st t when poll reach  delay  offset  jitter
==============================================================================
 LOCAL(0)        .LOCL.          10 l  27h  64    0    0.000    0.000  0.000
*pneumatix.linoc 192.12.19.20    2 u  762 1024  377  1319.53  -82.225  40.967
+w1-wdc.ipv4.got 10.0.77.54      4 u  542 1024  377  1568.59  -78.196 127.785
+ntp1.websters-c 192.43.244.18    2 u  891 1024  157  1367.28  25.168  73.369

The asterisk indicates that we're synced with the stratum 2 server at pneumatix.linoc. The plus signs are candidates if that server drops off line.

Note that you must have one or two DNS server addresses in /etc/resolv.conf for this display (and, of course, for your browser to find anything too). If you prefer to have a faster response for this display use
Code:

/usr/sbin/ntpq -pn 
    remote          refid      st t when poll reach  delay  offset  jitter
==============================================================================
 127.127.1.0    .LOCL.          10 l  27h  64    0    0.000    0.000  0.000
*69.64.72.238    192.12.19.20    2 u  119 1024  377  1319.53  -82.225  57.495
+173.193.227.67  10.0.77.54      4 u  944 1024  377  1568.59  -78.196 127.785
+38.109.218.175  192.43.244.18    2 u  269 1024  337  1367.28  25.168  75.813

so you don't have to wait for the DNS look up.

Lessons learned during a wasted youth.


All times are GMT -5. The time now is 03:43 PM.