Find the answer to your Linux question:
Results 1 to 5 of 5
Hi My clock is totally messed up. It is horribly out of sync and is extremely random. It throws itself off by hours at a time. Is there any way ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035

    Problem with Clock


    Hi
    My clock is totally messed up. It is horribly out of sync and is extremely random. It throws itself off by hours at a time. Is there any way I can have my clock display the time from some sort of time server? (Yoper v2)
    -lakerdonald

  2. #2
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682
    You can install ntp and use the program ntpdate <server>. Just find a server that you like, add it to your crontab and you're all set!
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

  3. #3
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    so then my clock in the lower-righthand corner of the screen will reflect that? cool
    Thanks
    -lakerdonald

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Aug 2004
    Location
    Seattle, Wa.
    Posts
    6
    From the Support forum at yoper.com

    Does the hamster in your computer not run fast enough, thereby causing your clock to lose a few minutes or hours? Who do those hamsters think they are!

    The solution is to use the Network Time Protocol (NTP). This guide will show you how to set up your computer to automatically update its clock when you want it to.

    First, open a console and do this:

    Code:
    su
    &#40;enter the root account's password&#41;
    apt-get update
    apt-get install ntp
    Now go to http://www.worldvisions.ca/~apenwarr/netselect/ and download the source code for netselect. Go into the directory where you downloaded netselect-0.3.tar.gz and do this:
    Code:
    tar -zxvf netselect-0.3.tar.gz
    cd netselect
    make
    su
    &#40;enter the root account's password&#41;
    make install
    Download the file I have attached to this topic and save it as /etc/ntp.list. I have copied and modified it from a nifty program called cmdtime3 (sadly, not available for Linux).

    Now open a console and do this:
    Code:
    su
    &#40;enter the root account's password&#41;
    netselect -vv -s 10 -t 25 $&#40;cat /etc/ntp.list&#41;
    This will use netselect to test the latency between your computer and the remote NTP time servers, using the ntp.list file as input for the list of servers to test. It will send 25 packets to at least half of the servers and in the end will show you a list of the top 10 servers after outputting some info (vv - very verbose).

    When I run it, I get this output:


    Code:
    root@yos jesse # netselect -vv -s 10 -t 25 $&#40;cat /etc/ntp.list&#41;
    Running netselect to choose 10 out of 75 addresses.
    &#91;Server details are displayed here - pretty interesting stuff!&#93;
      96 ntp.cs.strath.ac.uk
      129 ntp2c.mcc.ac.uk
      135 ntp2b.mcc.ac.uk
      137 ntp2a.mcc.ac.uk
      187 fartein.ifi.uio.no
      191 ntp.maths.tcd.ie
      260 louie.udel.edu
      358 timeserver.cs.umb.edu
      384 fuzz.psc.edu
      453 chime.utoronto.ca
    This shows that out of the 75 servers tested, 10 of them had pings roughly 453 milliseconds or less. This is how long it takes to send a bit of information from my computer to the remote server and receive a reply back from it. There are 1000 milliseconds in one second.

    From my results, I can see that six of the top ten servers were in the UK or Ireland. I will use them as they are closest to me and therefore faster than the rest. Your results will most likely vary from mine, so please do run the test yourself to get correct results.

    Now to set up your computer to automatically update your clock, open a console and do this:
    Code:
    su
    &#40;enter the root account's password&#41;
    crontab -e
    When nano (a simple to use console-based text editor) opens up, you need to add a line like this right after the last one:
    Code:
    0 0,8,16 * * * ntpdate ntp.cs.strath.ac.uk ntp2a.mcc.ac.uk ntp2b.mcc.ac.uk ntp2c.mcc.ac.uk ntp2d.mcc.ac.uk ntp.maths.tcd.ie
    Make sure to leave an extra spare line at the end of the file.

    The above line tells your computer to update its clock at midnight, 8 am and 4 pm on the hour, every day and month, no matter which day of the week it is, from the servers your provide it with. You might not want to do it that often, in which case you just change the "0,8,16" part to the hours when your computer is on and you'd like it to update its clock.

    This is where the results from netselect come in. You'll need to change the names of the servers I have used (after ntpdate) to be specific to you.

    If you would rather update your clock manually (i.e. not at set times), you can still run ntpdate from your console by doing this:

    Code:
    su
    &#40;enter the root account's password&#41;
    ntpdate ntp.cs.strath.ac.uk ntp2a.mcc.ac.uk ntp2b.mcc.ac.uk ntp2c.mcc.ac.uk ntp2d.mcc.ac.uk ntp.maths.tcd.ie
    Remember to change the list of servers you give it. This is the output I get from the above line:
    Code:
    root@yos jesse # ntpdate ntp.cs.strath.ac.uk ntp2a.mcc.ac.uk ntp2b.mcc.ac.uk ntp2c.mcc.ac.uk ntp2d.mcc.ac.uk ntp.maths.tcd.ie
    Looking for host ntp.cs.strath.ac.uk and service ntp
    host found &#58; ntp0.cis.strath.ac.uk
    Looking for host ntp2a.mcc.ac.uk and service ntp
    host found &#58; maverick.mcc.ac.uk
    Looking for host ntp2b.mcc.ac.uk and service ntp
    host found &#58; veracity.mcc.ac.uk
    Looking for host ntp2c.mcc.ac.uk and service ntp
    host found &#58; utserv.mcc.ac.uk
    Looking for host ntp2d.mcc.ac.uk and service ntp
    host found &#58; scarp.mc.man.ac.uk
    Looking for host ntp.maths.tcd.ie and service ntp
    host found &#58; lanczos.maths.tcd.ie
    7 Sep 21&#58;54&#58;45 ntpdate&#91;15311&#93;&#58; step time server 130.88.200.6 offset -1.119338 sec
    I hope this is of help to the users with old and fragile hamsters running around in their computers!
    good luck

  6. #5
    Just Joined!
    Join Date
    Sep 2004
    Posts
    4
    That will work, granted that it's not your cmos battery going bad, I'm having the same problem and I believe it's my battery. My laptop will loose anywhere from 20 min while I've got it up and running to an hour if I leave it unplugged from wall socket. Not a fun thing I tell you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •