LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 03-20-2012, 03:47 PM   #1
jdgr
Member
 
Registered: Feb 2012
Location: Ontario, Canada
Distribution: Fedora 18
Posts: 65

Rep: Reputation: Disabled
Question 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.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 03-20-2012, 04:16 PM   #2
camorri
Senior Member
 
Registered: Nov 2002
Location: Somewhere inside 9.9 million sq. km. Canada
Distribution: Slackware 14.1
Posts: 4,851

Rep: Reputation: 432Reputation: 432Reputation: 432Reputation: 432Reputation: 432
This link covers setting the clock, and setting up ntpd daemon.

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

Hope this helps.
 
Old 03-20-2012, 05:38 PM   #3
KeithE
Member
 
Registered: Jan 2003
Location: Phoenix, AZ
Distribution: Mint, Slackware
Posts: 88

Rep: Reputation: 19
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
 
Old 03-20-2012, 07:04 PM   #4
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 3,461

Rep: Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852
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.
 
Old 03-21-2012, 05:22 AM   #5
GazL
Senior Member
 
Registered: May 2008
Posts: 3,426

Rep: Reputation: 937Reputation: 937Reputation: 937Reputation: 937Reputation: 937Reputation: 937Reputation: 937Reputation: 937
Quote:
Originally Posted by allend View Post
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.
 
Old 03-21-2012, 06:55 AM   #6
jdgr
Member
 
Registered: Feb 2012
Location: Ontario, Canada
Distribution: Fedora 18
Posts: 65

Original Poster
Rep: Reputation: Disabled
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.
 
Old 03-21-2012, 10:34 AM   #7
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 3,461

Rep: Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852Reputation: 852
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.
 
Old 03-21-2012, 11:00 AM   #8
aocab
Member
 
Registered: Nov 2009
Location: Heart of Texas
Distribution: Slackware-current
Posts: 138

Rep: Reputation: 30
Quote:
Originally Posted by GazL View Post
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
 
2 members found this post helpful.
Old 03-21-2012, 02:09 PM   #9
GazL
Senior Member
 
Registered: May 2008
Posts: 3,426

Rep: Reputation: 937Reputation: 937Reputation: 937Reputation: 937Reputation: 937Reputation: 937Reputation: 937Reputation: 937
Thanks for that aocab And yes, it does the same here. Now I'm wondering whether that's a bug or a feature.
 
Old 03-22-2012, 08:55 AM   #10
jdgr
Member
 
Registered: Feb 2012
Location: Ontario, Canada
Distribution: Fedora 18
Posts: 65

Original Poster
Rep: Reputation: Disabled
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.
 
Old 03-22-2012, 10:54 AM   #11
interndan
Member
 
Registered: Aug 2004
Location: near Marion, Ill
Distribution: Slackware 13.37
Posts: 238

Rep: Reputation: 17
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
 
Old 03-22-2012, 01:25 PM   #12
jdgr
Member
 
Registered: Feb 2012
Location: Ontario, Canada
Distribution: Fedora 18
Posts: 65

Original Poster
Rep: Reputation: Disabled
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.
 
Old 03-22-2012, 01:32 PM   #13
interndan
Member
 
Registered: Aug 2004
Location: near Marion, Ill
Distribution: Slackware 13.37
Posts: 238

Rep: Reputation: 17
If you don't want to reboot after you create the file, just issue (as root) /etc/cron.daily/settime.
 
Old 10-20-2012, 02:03 PM   #14
zarglink
LQ Newbie
 
Registered: Feb 2012
Location: right coast oo ess aye
Distribution: slackware, knoppix, grml, FreeBSD
Posts: 4

Rep: Reputation: Disabled
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
 
Old 10-21-2012, 10:09 AM   #15
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,077

Rep: Reputation: 786Reputation: 786Reputation: 786Reputation: 786Reputation: 786Reputation: 786Reputation: 786
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.

Last edited by tronayne; 10-21-2012 at 10:11 AM.
 
  


Reply

Tags
slackware


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set Time Zone under xfce cccc Debian 2 03-17-2011 11:17 AM
Time skew of 580 min when I set my time zone in Gentoo scooter2 Linux - Newbie 1 03-05-2009 10:27 AM
Where does RH8 daily set system time to hardware clock time smartnorman Red Hat 1 05-24-2006 02:42 PM
Cannot set time/date to other time zone than UTC (Kubuntu) jamangold Ubuntu 1 12-23-2005 05:42 PM
Doub about `net time set` and daylight saving time Thakowbbery Linux - Software 0 10-17-2005 05:23 AM


All times are GMT -5. The time now is 04:54 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration