How to force a clock update using ntp?How to make sure my computer clock is right and fix it if it is not?Clock time is off on dual bootWhat is the command to update time and date from internetntpdate: no server suitable for synchronization foundIs there a way to make ntpd -gq run fasterHow do I force Ubuntu to resynchronize the system time?When even ntpd doesn't sync timeSetting up ntp serverClock drift even though NTPD runningenable/disabling NTP serverHow to sync time ubuntu desktop 13.10 client with Centos6.4 server using ntpntpdate: no server suitable for synchronization foundissue : USB-LIVE Lubuntu ntpdate time is not getting syncWhen even ntpd doesn't sync timeNTP Synchronization issue & it turned off automaticallyNTP service does not seen in ps auxntp server is not working correct at startup14.04 not keeping ntp time with ntpdate and datetimectl

Can compressed videos be decoded back to their uncompresed original format?

How seriously should I take size and weight limits of hand luggage?

Knowledge-based authentication using Domain-driven Design in C#

Send out email when Apex Queueable fails and test it

Solving an equation with constraints

Could the museum Saturn V's be refitted for one more flight?

Finitely generated matrix groups whose eigenvalues are all algebraic

Why are UK visa biometrics appointments suspended at USCIS Application Support Centers?

Finding the reason behind the value of the integral.

How to remove border from elements in the last row?

Do creatures with a listed speed of "0 ft., fly 30 ft. (hover)" ever touch the ground?

my venezuela girlfriend wants to travel the USA where i live.what does she need to do and how expensive will it become or how difficult?

how do we prove that a sum of two periods is still a period?

Machine learning testing data

Sums of two squares in arithmetic progressions

Mathematica command that allows it to read my intentions

If a warlock makes a Dancing Sword their pact weapon, is there a way to prevent it from disappearing if it's farther away for more than a minute?

What exactly is ineptocracy?

files created then deleted at every second in tmp directory

Rotate ASCII Art by 45 Degrees

Theorists sure want true answers to this!

What is the fastest integer factorization to break RSA?

Using "tail" to follow a file without displaying the most recent lines

How to stretch the corners of this image so that it looks like a perfect rectangle?



How to force a clock update using ntp?


How to make sure my computer clock is right and fix it if it is not?Clock time is off on dual bootWhat is the command to update time and date from internetntpdate: no server suitable for synchronization foundIs there a way to make ntpd -gq run fasterHow do I force Ubuntu to resynchronize the system time?When even ntpd doesn't sync timeSetting up ntp serverClock drift even though NTPD runningenable/disabling NTP serverHow to sync time ubuntu desktop 13.10 client with Centos6.4 server using ntpntpdate: no server suitable for synchronization foundissue : USB-LIVE Lubuntu ntpdate time is not getting syncWhen even ntpd doesn't sync timeNTP Synchronization issue & it turned off automaticallyNTP service does not seen in ps auxntp server is not working correct at startup14.04 not keeping ntp time with ntpdate and datetimectl













358















I am running Ubuntu on an ARM based embedded system that lacks a battery backed RTC. The wake-up time is somewhere during 1970. Thus, I use the NTP service to update the time to the current time.



I added the following line to /etc/rc.local file:



sudo ntpdate -s time.nist.gov


However, after startup, it still takes a couple of minutes until the time is updated, during which period I cannot work effectively with tar and make.



How can I force a clock update at any given time?




UPDATE 1: The following (thanks to Eric and Stephan) works fine from command line, but fails to update the clock when put in /etc/rc.local:



$ date ; sudo service ntp stop ; sudo ntpdate -s time.nist.gov ; sudo service ntp start ; date
Thu Jan 1 00:00:58 UTC 1970
* Stopping NTP server ntpd [ OK ]
* Starting NTP server [ OK ]
Thu Feb 14 18:52:21 UTC 2013


What am I doing wrong?




UPDATE 2: I tried following the few suggestions that came in response to the 1st update, but nothing seems to actually do the job as required. Here's what I tried:



  1. Replace the server to us.pool.ntp.org

  2. Use explicit paths to the programs

  3. Remove the ntp service altogether and leave just sudo ntpdate ... in rc.local

  4. Remove the sudo from the above command in rc.local

Using the above, the machine still starts at 1970. However, when doing this from command line once logged in (via ssh), the clock gets updated as soon as I invoke ntpdate.



Last thing I did was to remove that from rc.local and place a call to ntpdate in my .bashrc file. This does update the clock as expected, and I get the true current time once the command prompt is available.



However, this means that if the machine is turned on and no user is logged in, then the time never gets updates. I can, of course, reinstall the ntp service so at least the clock is updated within a few minutes from startup, but then we're back at square 1.



So, is there a reason why placing the ntpdate command in rc.local does not perform the required task, while doing so in .bashrc works fine?










share|improve this question



















  • 2





    from [here][1]: ntpdate -s ntp.ubuntu.com [1]: askubuntu.com/a/81301/130162

    – 18446744073709551615
    May 28 '15 at 7:27







  • 3





    notice the '-b' flag on ntpdate. From ntpdate's man page: "Force the time to be stepped using the settimeofday() system call, rather than slewed (default) using the adjtime() system call. This option should be used when called from a startup file at boot time." Many of the answers below do not include it, and that maybe part of the problem in getting things to work. Consider that the the '-B' flag it mentions that offsets over 128 ms can take hours to sync using the default 'slew' mechanism

    – Matt S.
    Jun 22 '15 at 6:39











  • There are no need to use sudo in /etc/rc.locale files .. they are allready run as root.

    – Soren A
    Jun 1 '17 at 12:12















358















I am running Ubuntu on an ARM based embedded system that lacks a battery backed RTC. The wake-up time is somewhere during 1970. Thus, I use the NTP service to update the time to the current time.



I added the following line to /etc/rc.local file:



sudo ntpdate -s time.nist.gov


However, after startup, it still takes a couple of minutes until the time is updated, during which period I cannot work effectively with tar and make.



How can I force a clock update at any given time?




UPDATE 1: The following (thanks to Eric and Stephan) works fine from command line, but fails to update the clock when put in /etc/rc.local:



$ date ; sudo service ntp stop ; sudo ntpdate -s time.nist.gov ; sudo service ntp start ; date
Thu Jan 1 00:00:58 UTC 1970
* Stopping NTP server ntpd [ OK ]
* Starting NTP server [ OK ]
Thu Feb 14 18:52:21 UTC 2013


What am I doing wrong?




UPDATE 2: I tried following the few suggestions that came in response to the 1st update, but nothing seems to actually do the job as required. Here's what I tried:



  1. Replace the server to us.pool.ntp.org

  2. Use explicit paths to the programs

  3. Remove the ntp service altogether and leave just sudo ntpdate ... in rc.local

  4. Remove the sudo from the above command in rc.local

Using the above, the machine still starts at 1970. However, when doing this from command line once logged in (via ssh), the clock gets updated as soon as I invoke ntpdate.



Last thing I did was to remove that from rc.local and place a call to ntpdate in my .bashrc file. This does update the clock as expected, and I get the true current time once the command prompt is available.



However, this means that if the machine is turned on and no user is logged in, then the time never gets updates. I can, of course, reinstall the ntp service so at least the clock is updated within a few minutes from startup, but then we're back at square 1.



So, is there a reason why placing the ntpdate command in rc.local does not perform the required task, while doing so in .bashrc works fine?










share|improve this question



















  • 2





    from [here][1]: ntpdate -s ntp.ubuntu.com [1]: askubuntu.com/a/81301/130162

    – 18446744073709551615
    May 28 '15 at 7:27







  • 3





    notice the '-b' flag on ntpdate. From ntpdate's man page: "Force the time to be stepped using the settimeofday() system call, rather than slewed (default) using the adjtime() system call. This option should be used when called from a startup file at boot time." Many of the answers below do not include it, and that maybe part of the problem in getting things to work. Consider that the the '-B' flag it mentions that offsets over 128 ms can take hours to sync using the default 'slew' mechanism

    – Matt S.
    Jun 22 '15 at 6:39











  • There are no need to use sudo in /etc/rc.locale files .. they are allready run as root.

    – Soren A
    Jun 1 '17 at 12:12













358












358








358


141






I am running Ubuntu on an ARM based embedded system that lacks a battery backed RTC. The wake-up time is somewhere during 1970. Thus, I use the NTP service to update the time to the current time.



I added the following line to /etc/rc.local file:



sudo ntpdate -s time.nist.gov


However, after startup, it still takes a couple of minutes until the time is updated, during which period I cannot work effectively with tar and make.



How can I force a clock update at any given time?




UPDATE 1: The following (thanks to Eric and Stephan) works fine from command line, but fails to update the clock when put in /etc/rc.local:



$ date ; sudo service ntp stop ; sudo ntpdate -s time.nist.gov ; sudo service ntp start ; date
Thu Jan 1 00:00:58 UTC 1970
* Stopping NTP server ntpd [ OK ]
* Starting NTP server [ OK ]
Thu Feb 14 18:52:21 UTC 2013


What am I doing wrong?




UPDATE 2: I tried following the few suggestions that came in response to the 1st update, but nothing seems to actually do the job as required. Here's what I tried:



  1. Replace the server to us.pool.ntp.org

  2. Use explicit paths to the programs

  3. Remove the ntp service altogether and leave just sudo ntpdate ... in rc.local

  4. Remove the sudo from the above command in rc.local

Using the above, the machine still starts at 1970. However, when doing this from command line once logged in (via ssh), the clock gets updated as soon as I invoke ntpdate.



Last thing I did was to remove that from rc.local and place a call to ntpdate in my .bashrc file. This does update the clock as expected, and I get the true current time once the command prompt is available.



However, this means that if the machine is turned on and no user is logged in, then the time never gets updates. I can, of course, reinstall the ntp service so at least the clock is updated within a few minutes from startup, but then we're back at square 1.



So, is there a reason why placing the ntpdate command in rc.local does not perform the required task, while doing so in .bashrc works fine?










share|improve this question
















I am running Ubuntu on an ARM based embedded system that lacks a battery backed RTC. The wake-up time is somewhere during 1970. Thus, I use the NTP service to update the time to the current time.



I added the following line to /etc/rc.local file:



sudo ntpdate -s time.nist.gov


However, after startup, it still takes a couple of minutes until the time is updated, during which period I cannot work effectively with tar and make.



How can I force a clock update at any given time?




UPDATE 1: The following (thanks to Eric and Stephan) works fine from command line, but fails to update the clock when put in /etc/rc.local:



$ date ; sudo service ntp stop ; sudo ntpdate -s time.nist.gov ; sudo service ntp start ; date
Thu Jan 1 00:00:58 UTC 1970
* Stopping NTP server ntpd [ OK ]
* Starting NTP server [ OK ]
Thu Feb 14 18:52:21 UTC 2013


What am I doing wrong?




UPDATE 2: I tried following the few suggestions that came in response to the 1st update, but nothing seems to actually do the job as required. Here's what I tried:



  1. Replace the server to us.pool.ntp.org

  2. Use explicit paths to the programs

  3. Remove the ntp service altogether and leave just sudo ntpdate ... in rc.local

  4. Remove the sudo from the above command in rc.local

Using the above, the machine still starts at 1970. However, when doing this from command line once logged in (via ssh), the clock gets updated as soon as I invoke ntpdate.



Last thing I did was to remove that from rc.local and place a call to ntpdate in my .bashrc file. This does update the clock as expected, and I get the true current time once the command prompt is available.



However, this means that if the machine is turned on and no user is logged in, then the time never gets updates. I can, of course, reinstall the ntp service so at least the clock is updated within a few minutes from startup, but then we're back at square 1.



So, is there a reason why placing the ntpdate command in rc.local does not perform the required task, while doing so in .bashrc works fine?







ntp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 27 '15 at 1:00







ysap

















asked Feb 13 '13 at 21:58









ysapysap

2,766102636




2,766102636







  • 2





    from [here][1]: ntpdate -s ntp.ubuntu.com [1]: askubuntu.com/a/81301/130162

    – 18446744073709551615
    May 28 '15 at 7:27







  • 3





    notice the '-b' flag on ntpdate. From ntpdate's man page: "Force the time to be stepped using the settimeofday() system call, rather than slewed (default) using the adjtime() system call. This option should be used when called from a startup file at boot time." Many of the answers below do not include it, and that maybe part of the problem in getting things to work. Consider that the the '-B' flag it mentions that offsets over 128 ms can take hours to sync using the default 'slew' mechanism

    – Matt S.
    Jun 22 '15 at 6:39











  • There are no need to use sudo in /etc/rc.locale files .. they are allready run as root.

    – Soren A
    Jun 1 '17 at 12:12












  • 2





    from [here][1]: ntpdate -s ntp.ubuntu.com [1]: askubuntu.com/a/81301/130162

    – 18446744073709551615
    May 28 '15 at 7:27







  • 3





    notice the '-b' flag on ntpdate. From ntpdate's man page: "Force the time to be stepped using the settimeofday() system call, rather than slewed (default) using the adjtime() system call. This option should be used when called from a startup file at boot time." Many of the answers below do not include it, and that maybe part of the problem in getting things to work. Consider that the the '-B' flag it mentions that offsets over 128 ms can take hours to sync using the default 'slew' mechanism

    – Matt S.
    Jun 22 '15 at 6:39











  • There are no need to use sudo in /etc/rc.locale files .. they are allready run as root.

    – Soren A
    Jun 1 '17 at 12:12







2




2





from [here][1]: ntpdate -s ntp.ubuntu.com [1]: askubuntu.com/a/81301/130162

– 18446744073709551615
May 28 '15 at 7:27






from [here][1]: ntpdate -s ntp.ubuntu.com [1]: askubuntu.com/a/81301/130162

– 18446744073709551615
May 28 '15 at 7:27





3




3





notice the '-b' flag on ntpdate. From ntpdate's man page: "Force the time to be stepped using the settimeofday() system call, rather than slewed (default) using the adjtime() system call. This option should be used when called from a startup file at boot time." Many of the answers below do not include it, and that maybe part of the problem in getting things to work. Consider that the the '-B' flag it mentions that offsets over 128 ms can take hours to sync using the default 'slew' mechanism

– Matt S.
Jun 22 '15 at 6:39





notice the '-b' flag on ntpdate. From ntpdate's man page: "Force the time to be stepped using the settimeofday() system call, rather than slewed (default) using the adjtime() system call. This option should be used when called from a startup file at boot time." Many of the answers below do not include it, and that maybe part of the problem in getting things to work. Consider that the the '-B' flag it mentions that offsets over 128 ms can take hours to sync using the default 'slew' mechanism

– Matt S.
Jun 22 '15 at 6:39













There are no need to use sudo in /etc/rc.locale files .. they are allready run as root.

– Soren A
Jun 1 '17 at 12:12





There are no need to use sudo in /etc/rc.locale files .. they are allready run as root.

– Soren A
Jun 1 '17 at 12:12










16 Answers
16






active

oldest

votes


















312














Probably the ntp service is running, that's why ntpdate can't open the socket (port 123 UDP) and connect to ntp server.



Try from command line:



sudo service ntp stop
sudo ntpdate -s time.nist.gov
sudo service ntp start


If you want to put this in /etc/rc.local use the following:



( /etc/init.d/ntp stop
until ping -nq -c3 8.8.8.8; do
echo "Waiting for network..."
done
ntpdate -s time.nist.gov
/etc/init.d/ntp start )&





share|improve this answer

























  • Thanks. Can you please explain why you need the explicit paths?

    – ysap
    Feb 14 '13 at 21:06






  • 1





    I don't really know. :-) I had trouble once trying to run service from rc.local and cron but I managed to fix it using /etc/init.d/xxx instead. Actually I think you don't have to give the full path to ntpdate, I like to use full paths in scripts just to be sure the right file wiill be found.

    – Eric Carvalho
    Feb 14 '13 at 21:43







  • 2





    OK, this was apparently the problem. Now the clock is being updated as soon as the network connection is established. Thanks.

    – ysap
    Feb 16 '13 at 1:23






  • 3





    I did found out that the us.pool.ntp.org is more responsive.

    – ysap
    Feb 16 '13 at 1:25






  • 6





    With the -u option, you don't need to stop the ntp service: sudo ntpdate -u time.nist.gov

    – Edward Anderson
    Mar 3 '17 at 14:09


















460














Instead of ntpdate (which is deprecated), use



sudo service ntp stop
sudo ntpd -gq
sudo service ntp start


The -gq tells the ntp daemon to correct the time regardless of the offset (g) and exit immediately (q) after setting the time.






share|improve this answer




















  • 3





    Thanks. Still showing 1970 after this command (w/ sudo). Reading ntpd manpage, I am not sure how this forces an update?

    – ysap
    Feb 14 '13 at 18:42






  • 12





    The "-q" option tells the NTP daemon to start up, set the time and immediately exit. The "-g" option allows it to correct for time differences larger then 1000 sec. For longer term, you should simply configure the NTP daemon to be running always.

    – tgharold
    Sep 9 '13 at 18:16






  • 28





    This answer should go to the top, because it is correct: ntpdate is deprecated and installing it is a bad idea, because it conflicts with ntp. If the clock is way off, you need to do this manual step because otherwise ntp will not change your clock and will not tell you why.

    – Liam
    Feb 6 '14 at 21:11






  • 27





    For me, sudo ntpd -gq does not exit! I'm on 14.10 and I have to CTRL+C to continue... or how long is it supposed to take?

    – Yanick Rochon
    Jan 27 '15 at 2:41







  • 4





    FYI, on my system (CentOS 6.6), I needed to change the two instances of sudo service ntp... to sudo service ntpd....

    – rinogo
    Jan 27 '15 at 22:48


















54














Use sntp to set the time immediately. For example:



sudo sntp -s 24.56.178.140


The numbers after -s can be any ntp time server, that one is NIST in Ft. Collins, Colorado.






share|improve this answer


















  • 1





    That worked! +1

    – CappY
    Mar 23 '15 at 15:30






  • 6





    This worked when "sudo ntpd -gq" didn't.

    – Matt White
    Apr 29 '16 at 14:54











  • I don't know how many times I've come searching for this answer. Works every time.

    – Chaos
    Oct 12 '16 at 4:45






  • 1





    unable to locate package sntp ?

    – temple
    Apr 5 '17 at 17:54






  • 1





    apt-get install sntp / yum install sntp (yes it works on CentOS,RedHat,fedore too)

    – ndemou
    Dec 5 '17 at 7:40


















39














As others have pointed out the best solution is to instruct ntpd to ignore the panic threshold, which is 1000 seconds by default. You can configure the panic threshold in one of two ways:



  • edit /etc/default/ntp and ensure that the -g option is present.

  • edit /etc/ntp.conf and place tinker panic 0 at the top

So far this is essentially what others have recommended however there is one more step I think you should take. Install the fake-hwclock program:



# apt-get install fake-hwclock


fake-hwclock: Save/restore system clock on machines without working RTC hardware

Some machines don't have a working realtime clock (RTC) unit, or no
driver for the hardware that does exist. fake-hwclock is a simple set
of scripts to save the kernel's current clock periodically (including
at shutdown) and restore it at boot so that the system clock keeps at
least close to realtime. This will stop some of the problems that may
be caused by a system believing it has travelled in time back to
1970, such as needing to perform filesystem checks at every boot.

On top of this, use of NTP is still recommended to deal with the fake
clock "drifting" while the hardware is halted or rebooting.


With fake-hwclock installed your machine will not start up thinking it is 1970 all over again. When your machine boots up it will set its clock to the timestamp fake-hwclock wrote during the last reboot/shutdown. This means you can have a somewhat correct clock in case there are network issues when you boot up.






share|improve this answer


















  • 1





    -g seemed to do nothing for me (at the command line, I don't have /etc/default/ntp), but adding tinker panic 0 to ntp.conf worked

    – Dave Cousineau
    Aug 10 '17 at 1:36











  • @Sahuagin I don't know what to tell you other than you have a nonstandard ntp package. /etc/default/ntp is part of the package from Ubuntu: packages.ubuntu.com/xenial/amd64/ntp/filelist and -g has been an option for as long as I can remember.

    – dfc
    Aug 10 '17 at 1:52











  • sorry, I guess I'm not actually on Ubuntu and should have thought a little more before commenting. tinker panic 0 definitely seems to have worked though.

    – Dave Cousineau
    Aug 10 '17 at 20:21


















12














ntpdate is a program different from the net dameon. NTPDate is probably erroring out on boot because ntpd is running on that socket.



From the command line, run



# sudo service ntp stop ; sudo ntpdate -s time.nist.gov ; sudo service ntp start


You could also uninstall ntpd all together (apt-get remove ntp) and add a cron script to use ntpdate every hour or so.



UPDATE



ntp service probably won't have meaningful value for you on this system, so remove that first.



# sudo apt-get remove ntp


Now add the command:



ntpdate -sb time.nist.gov


to /etc/rclocal



Reboot. Should be good at that point.






share|improve this answer

























  • answer updated.

    – Stephan
    Feb 14 '13 at 19:53






  • 1





    Isn't ntpdate being phased out or something? Also, If I understand this correctly, the service runs and maintains the sync of the local clock to the server's clock - so the drift is bound. If you remove ntp and run ntpdate once, won't it be affected by clock drifting when the machine is on for extended periods?

    – ysap
    Feb 14 '13 at 21:07












  • Stephan, please see update #2 to the question.

    – ysap
    Feb 15 '13 at 21:42






  • 3





    Yes, ntpdate is being phased out. Use of "ntpd -q" is preferred (both variants require that ntpd be stopped first).

    – tgharold
    Sep 9 '13 at 18:17


















10














rdate -s tick.greyware.com


if all you want to do is set the clock once, simple






share|improve this answer























  • Thanks. I don't currently have the system to check this command, but if you follow the discussion in the question and the accepted answer, you'll see that the problem was actually network unavailability at the time of running the clock update command.

    – ysap
    Feb 27 '15 at 0:57











  • This fixed a time sync issue on my Raspberry Pi. Thank you.

    – Oliver Spryn
    Feb 15 '17 at 16:58


















7














The correct way to do this on a Debian / Mint / Ubuntu (or other Debian derivative) system is to have the line



NTPD_OPTS="-g"


in the file



/etc/default/ntp


This ensures that when ntpd is started from the /etc/init.d/ntp script, it runs with the "-g" option, viz



 start-stop-daemon --start --quiet --oknodo --pidfile /var/run/ntpd.pid --startas /usr/sbin/ntpd -- -p /var/run/ntpd.pid -g -u 124:128


to allow ntpd to correct the system time when it is more than 1000 s out, eg when the system time is January 1st 1970 on startup because there is no hardware RTC.






share|improve this answer























  • I have that already, but it still says 3AM in NY, when it should be 11pm.

    – chovy
    Jul 6 '14 at 3:07











  • I also already had exactly that line in /etc/default/ntp, but time wasn't synchronized.

    – Dawid Ferenczy
    Nov 10 '14 at 18:15


















4














Try using the -b option to step the time.






share|improve this answer


















  • 2





    When trying from command line, I get the following response: 1 Jan 00:04:11 ntpdate[2226]: the NTP socket is in use, exiting . However, I think that I tried this before in rc.local but it did not help.

    – ysap
    Feb 13 '13 at 22:28







  • 2





    You need to stop the ntp service first before you can run ntpdate -b <ipaddress>

    – Wim Deblauwe
    Nov 26 '14 at 13:02


















4














tlsdate sets the local clock by securely connecting with TLS to remote servers and extracting the remote time out of the secure handshake. Unlike
ntpdate, tlsdate uses TCP, for instance connecting to a remote HTTPS or TLS
enabled service, and provides some protection against adversaries that try to
feed you malicious time information.



$ tlsdate -V -n -H encrypted.google.com





share|improve this answer
































    4














    Use timedatectl (systemd service unit) to set the time. ntp is deprecated.



    sudo systemctl restart systemd-timesyncd.service


    You can check the time was updated reading the logs with journalctl -xe | tail



    Reference



    • Ubuntu Server documentation

    • Freedesktop

    • man timesyncd.conf





    share|improve this answer
































      2














      Well,



      I am running a raspbian (debian wheezy) on my raspberry pi, which doesn't have the hwclock. I found it handy to write a little script and run it after my internet interface is up, so that I am sure that the moment the network becomes available, the clock gets updated.



      First check that you have the ntpdate package by running



      sudo apt-get update
      sudo apt-get install ntpdate


      You need to add the following into your /etc/network/interfaces (surely eth0 here is just an example):



      auto eth0
      iface eth0 inet dhcp
      post-up /usr/local/sbin/update-time.sh


      And create the following script in /usr/local/sbin/update-time.sh (don't forget to make it executable by chmod):



      #!/bin/bash
      # This script checks if the ntp process is running, stops it, updates the system time, starts it again

      ps cax | grep -c ntpd > /dev/null
      onoff=$?
      if [ "$onoff" -gt 0 ]; then
      echo "stopping ntpd..."
      service ntp stop
      echo "ntpd stopped"
      else
      echo "ntpd not running, ready to update the date"
      fi


      isinstalled=$(dpkg-query -l | grep -c ntpdate)
      if [ "$isinstalled" -gt 0 ]; then
      ntpdate -t 3 -s ntp4.stratum2.ru
      echo "date and time update executed"
      else
      echo "ntpdate package not installed, can't update using ntp"
      fi

      echo "restarting ntpd..."
      service ntp start
      echo "ntpd running"
      echo "printing current date and time:"
      date

      exit





      share|improve this answer






























        2














        Note that some current Ubuntu based systems don't even use the NTP service by default now. On my Linux Mint 19 (Ubuntu 18.04) machine, time is kept by systemd-timesyncd.



        So to get an up to date time after it has lost sync, I just run



        sudo systemctl restart systemd-timesyncd


        Since 15.04 Ubuntu uses systemd by default. Therefore critical systems like time are managed through systemd. To find what service your system is using run something like



        systemctl list-unit-files | grep -E 'ntp|timesyncd'


        For TechJS on 16.04 the service was ntp. For myself on Ubuntu 18.04 (Mint 19) the service is systemd-timesyncd. Interestingly, I logged into a 16.04 server I have and it uses systemd-timesyncd as well.






        share|improve this answer

























        • Thanks. It has been a long time since posting the question, and I don't have a system available for testing, but can you elaborate on how is your answer different from @TechJS , especially the command you proposed is slightly different.

          – ysap
          Nov 29 '18 at 17:37











        • Ha thanks. It was a response to you but also to anyone who in the future finds themselves here without more up to date information (like myself). I updated my answer to be more specific on how I reach my answer.

          – Aaron Chamberlain
          Nov 29 '18 at 18:52


















        1














        The ntpd algorithms discard sample offsets exceeding 128 ms, unless the interval during which no [absolute value of] sample offset is less than 128 ms exceeds 900s. The first sample after that, no matter what the offset, steps the clock to the indicated time. In practice this reduces the false alarm rate where the clock is stepped in error to a vanishingly low incidence.



        Normally, ntpd exits if the offset exceeds the sanity limit, which is 1000 s by default. This can be turned off with the -g option:



        -g
        Normally, ntpd exits if the offset exceeds the sanity limit, which is 1000 s by default. If the sanity limit is set to zero, no sanity checking is performed and any offset is acceptable. This option overrides the limit and allows the time to be set to any value without restriction; however, this can happen only once. After that, ntpd will exit if the limit is exceeded. This option can be used with the -q option.



        both from http://doc.ntp.org/4.1.0/ntpd.htm



        -Jonathan Natale






        share|improve this answer
































          1














          If you are on systemd you could use this command:



          sudo systemctl restart ntp
          # or
          sudo systemctl restart ntp.service


          And then the time gets updated within near 10-15 seconds.

          Tested on ubuntu mate 16.04






          share|improve this answer






























            0














            ntpd and ntpdate run by default using a restricted port (UDP 123). If you are behind a firewall, ntpd will never work, but ntpdate can work with the -u option. For example: ntpdate -u 0.ubuntu.pool.ntp.org or ntpdate -u time.nist.gov should both work fine.






            share|improve this answer
































              0














              If you can afford the time to wait whatever time it takes before your system gets in sync, you can use the ntp-wait command:



              ntp-wait || exit -1 
              # i believe this would exit the script if it fails, but not sure of ntp-wait return codes, learn this first.

              echo Time is synced, go ahead with backup
              tar
              rsync etc.





              share|improve this answer

























                Your Answer








                StackExchange.ready(function()
                var channelOptions =
                tags: "".split(" "),
                id: "89"
                ;
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function()
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled)
                StackExchange.using("snippets", function()
                createEditor();
                );

                else
                createEditor();

                );

                function createEditor()
                StackExchange.prepareEditor(
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader:
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                ,
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                );



                );













                draft saved

                draft discarded


















                StackExchange.ready(
                function ()
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f254826%2fhow-to-force-a-clock-update-using-ntp%23new-answer', 'question_page');

                );

                Post as a guest















                Required, but never shown

























                16 Answers
                16






                active

                oldest

                votes








                16 Answers
                16






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                312














                Probably the ntp service is running, that's why ntpdate can't open the socket (port 123 UDP) and connect to ntp server.



                Try from command line:



                sudo service ntp stop
                sudo ntpdate -s time.nist.gov
                sudo service ntp start


                If you want to put this in /etc/rc.local use the following:



                ( /etc/init.d/ntp stop
                until ping -nq -c3 8.8.8.8; do
                echo "Waiting for network..."
                done
                ntpdate -s time.nist.gov
                /etc/init.d/ntp start )&





                share|improve this answer

























                • Thanks. Can you please explain why you need the explicit paths?

                  – ysap
                  Feb 14 '13 at 21:06






                • 1





                  I don't really know. :-) I had trouble once trying to run service from rc.local and cron but I managed to fix it using /etc/init.d/xxx instead. Actually I think you don't have to give the full path to ntpdate, I like to use full paths in scripts just to be sure the right file wiill be found.

                  – Eric Carvalho
                  Feb 14 '13 at 21:43







                • 2





                  OK, this was apparently the problem. Now the clock is being updated as soon as the network connection is established. Thanks.

                  – ysap
                  Feb 16 '13 at 1:23






                • 3





                  I did found out that the us.pool.ntp.org is more responsive.

                  – ysap
                  Feb 16 '13 at 1:25






                • 6





                  With the -u option, you don't need to stop the ntp service: sudo ntpdate -u time.nist.gov

                  – Edward Anderson
                  Mar 3 '17 at 14:09















                312














                Probably the ntp service is running, that's why ntpdate can't open the socket (port 123 UDP) and connect to ntp server.



                Try from command line:



                sudo service ntp stop
                sudo ntpdate -s time.nist.gov
                sudo service ntp start


                If you want to put this in /etc/rc.local use the following:



                ( /etc/init.d/ntp stop
                until ping -nq -c3 8.8.8.8; do
                echo "Waiting for network..."
                done
                ntpdate -s time.nist.gov
                /etc/init.d/ntp start )&





                share|improve this answer

























                • Thanks. Can you please explain why you need the explicit paths?

                  – ysap
                  Feb 14 '13 at 21:06






                • 1





                  I don't really know. :-) I had trouble once trying to run service from rc.local and cron but I managed to fix it using /etc/init.d/xxx instead. Actually I think you don't have to give the full path to ntpdate, I like to use full paths in scripts just to be sure the right file wiill be found.

                  – Eric Carvalho
                  Feb 14 '13 at 21:43







                • 2





                  OK, this was apparently the problem. Now the clock is being updated as soon as the network connection is established. Thanks.

                  – ysap
                  Feb 16 '13 at 1:23






                • 3





                  I did found out that the us.pool.ntp.org is more responsive.

                  – ysap
                  Feb 16 '13 at 1:25






                • 6





                  With the -u option, you don't need to stop the ntp service: sudo ntpdate -u time.nist.gov

                  – Edward Anderson
                  Mar 3 '17 at 14:09













                312












                312








                312







                Probably the ntp service is running, that's why ntpdate can't open the socket (port 123 UDP) and connect to ntp server.



                Try from command line:



                sudo service ntp stop
                sudo ntpdate -s time.nist.gov
                sudo service ntp start


                If you want to put this in /etc/rc.local use the following:



                ( /etc/init.d/ntp stop
                until ping -nq -c3 8.8.8.8; do
                echo "Waiting for network..."
                done
                ntpdate -s time.nist.gov
                /etc/init.d/ntp start )&





                share|improve this answer















                Probably the ntp service is running, that's why ntpdate can't open the socket (port 123 UDP) and connect to ntp server.



                Try from command line:



                sudo service ntp stop
                sudo ntpdate -s time.nist.gov
                sudo service ntp start


                If you want to put this in /etc/rc.local use the following:



                ( /etc/init.d/ntp stop
                until ping -nq -c3 8.8.8.8; do
                echo "Waiting for network..."
                done
                ntpdate -s time.nist.gov
                /etc/init.d/ntp start )&






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Feb 15 '13 at 23:40

























                answered Feb 13 '13 at 23:13









                Eric CarvalhoEric Carvalho

                42.4k17116147




                42.4k17116147












                • Thanks. Can you please explain why you need the explicit paths?

                  – ysap
                  Feb 14 '13 at 21:06






                • 1





                  I don't really know. :-) I had trouble once trying to run service from rc.local and cron but I managed to fix it using /etc/init.d/xxx instead. Actually I think you don't have to give the full path to ntpdate, I like to use full paths in scripts just to be sure the right file wiill be found.

                  – Eric Carvalho
                  Feb 14 '13 at 21:43







                • 2





                  OK, this was apparently the problem. Now the clock is being updated as soon as the network connection is established. Thanks.

                  – ysap
                  Feb 16 '13 at 1:23






                • 3





                  I did found out that the us.pool.ntp.org is more responsive.

                  – ysap
                  Feb 16 '13 at 1:25






                • 6





                  With the -u option, you don't need to stop the ntp service: sudo ntpdate -u time.nist.gov

                  – Edward Anderson
                  Mar 3 '17 at 14:09

















                • Thanks. Can you please explain why you need the explicit paths?

                  – ysap
                  Feb 14 '13 at 21:06






                • 1





                  I don't really know. :-) I had trouble once trying to run service from rc.local and cron but I managed to fix it using /etc/init.d/xxx instead. Actually I think you don't have to give the full path to ntpdate, I like to use full paths in scripts just to be sure the right file wiill be found.

                  – Eric Carvalho
                  Feb 14 '13 at 21:43







                • 2





                  OK, this was apparently the problem. Now the clock is being updated as soon as the network connection is established. Thanks.

                  – ysap
                  Feb 16 '13 at 1:23






                • 3





                  I did found out that the us.pool.ntp.org is more responsive.

                  – ysap
                  Feb 16 '13 at 1:25






                • 6





                  With the -u option, you don't need to stop the ntp service: sudo ntpdate -u time.nist.gov

                  – Edward Anderson
                  Mar 3 '17 at 14:09
















                Thanks. Can you please explain why you need the explicit paths?

                – ysap
                Feb 14 '13 at 21:06





                Thanks. Can you please explain why you need the explicit paths?

                – ysap
                Feb 14 '13 at 21:06




                1




                1





                I don't really know. :-) I had trouble once trying to run service from rc.local and cron but I managed to fix it using /etc/init.d/xxx instead. Actually I think you don't have to give the full path to ntpdate, I like to use full paths in scripts just to be sure the right file wiill be found.

                – Eric Carvalho
                Feb 14 '13 at 21:43






                I don't really know. :-) I had trouble once trying to run service from rc.local and cron but I managed to fix it using /etc/init.d/xxx instead. Actually I think you don't have to give the full path to ntpdate, I like to use full paths in scripts just to be sure the right file wiill be found.

                – Eric Carvalho
                Feb 14 '13 at 21:43





                2




                2





                OK, this was apparently the problem. Now the clock is being updated as soon as the network connection is established. Thanks.

                – ysap
                Feb 16 '13 at 1:23





                OK, this was apparently the problem. Now the clock is being updated as soon as the network connection is established. Thanks.

                – ysap
                Feb 16 '13 at 1:23




                3




                3





                I did found out that the us.pool.ntp.org is more responsive.

                – ysap
                Feb 16 '13 at 1:25





                I did found out that the us.pool.ntp.org is more responsive.

                – ysap
                Feb 16 '13 at 1:25




                6




                6





                With the -u option, you don't need to stop the ntp service: sudo ntpdate -u time.nist.gov

                – Edward Anderson
                Mar 3 '17 at 14:09





                With the -u option, you don't need to stop the ntp service: sudo ntpdate -u time.nist.gov

                – Edward Anderson
                Mar 3 '17 at 14:09













                460














                Instead of ntpdate (which is deprecated), use



                sudo service ntp stop
                sudo ntpd -gq
                sudo service ntp start


                The -gq tells the ntp daemon to correct the time regardless of the offset (g) and exit immediately (q) after setting the time.






                share|improve this answer




















                • 3





                  Thanks. Still showing 1970 after this command (w/ sudo). Reading ntpd manpage, I am not sure how this forces an update?

                  – ysap
                  Feb 14 '13 at 18:42






                • 12





                  The "-q" option tells the NTP daemon to start up, set the time and immediately exit. The "-g" option allows it to correct for time differences larger then 1000 sec. For longer term, you should simply configure the NTP daemon to be running always.

                  – tgharold
                  Sep 9 '13 at 18:16






                • 28





                  This answer should go to the top, because it is correct: ntpdate is deprecated and installing it is a bad idea, because it conflicts with ntp. If the clock is way off, you need to do this manual step because otherwise ntp will not change your clock and will not tell you why.

                  – Liam
                  Feb 6 '14 at 21:11






                • 27





                  For me, sudo ntpd -gq does not exit! I'm on 14.10 and I have to CTRL+C to continue... or how long is it supposed to take?

                  – Yanick Rochon
                  Jan 27 '15 at 2:41







                • 4





                  FYI, on my system (CentOS 6.6), I needed to change the two instances of sudo service ntp... to sudo service ntpd....

                  – rinogo
                  Jan 27 '15 at 22:48















                460














                Instead of ntpdate (which is deprecated), use



                sudo service ntp stop
                sudo ntpd -gq
                sudo service ntp start


                The -gq tells the ntp daemon to correct the time regardless of the offset (g) and exit immediately (q) after setting the time.






                share|improve this answer




















                • 3





                  Thanks. Still showing 1970 after this command (w/ sudo). Reading ntpd manpage, I am not sure how this forces an update?

                  – ysap
                  Feb 14 '13 at 18:42






                • 12





                  The "-q" option tells the NTP daemon to start up, set the time and immediately exit. The "-g" option allows it to correct for time differences larger then 1000 sec. For longer term, you should simply configure the NTP daemon to be running always.

                  – tgharold
                  Sep 9 '13 at 18:16






                • 28





                  This answer should go to the top, because it is correct: ntpdate is deprecated and installing it is a bad idea, because it conflicts with ntp. If the clock is way off, you need to do this manual step because otherwise ntp will not change your clock and will not tell you why.

                  – Liam
                  Feb 6 '14 at 21:11






                • 27





                  For me, sudo ntpd -gq does not exit! I'm on 14.10 and I have to CTRL+C to continue... or how long is it supposed to take?

                  – Yanick Rochon
                  Jan 27 '15 at 2:41







                • 4





                  FYI, on my system (CentOS 6.6), I needed to change the two instances of sudo service ntp... to sudo service ntpd....

                  – rinogo
                  Jan 27 '15 at 22:48













                460












                460








                460







                Instead of ntpdate (which is deprecated), use



                sudo service ntp stop
                sudo ntpd -gq
                sudo service ntp start


                The -gq tells the ntp daemon to correct the time regardless of the offset (g) and exit immediately (q) after setting the time.






                share|improve this answer















                Instead of ntpdate (which is deprecated), use



                sudo service ntp stop
                sudo ntpd -gq
                sudo service ntp start


                The -gq tells the ntp daemon to correct the time regardless of the offset (g) and exit immediately (q) after setting the time.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jun 1 '17 at 12:09

























                answered Feb 14 '13 at 12:32









                Martin SchröderMartin Schröder

                5,25111231




                5,25111231







                • 3





                  Thanks. Still showing 1970 after this command (w/ sudo). Reading ntpd manpage, I am not sure how this forces an update?

                  – ysap
                  Feb 14 '13 at 18:42






                • 12





                  The "-q" option tells the NTP daemon to start up, set the time and immediately exit. The "-g" option allows it to correct for time differences larger then 1000 sec. For longer term, you should simply configure the NTP daemon to be running always.

                  – tgharold
                  Sep 9 '13 at 18:16






                • 28





                  This answer should go to the top, because it is correct: ntpdate is deprecated and installing it is a bad idea, because it conflicts with ntp. If the clock is way off, you need to do this manual step because otherwise ntp will not change your clock and will not tell you why.

                  – Liam
                  Feb 6 '14 at 21:11






                • 27





                  For me, sudo ntpd -gq does not exit! I'm on 14.10 and I have to CTRL+C to continue... or how long is it supposed to take?

                  – Yanick Rochon
                  Jan 27 '15 at 2:41







                • 4





                  FYI, on my system (CentOS 6.6), I needed to change the two instances of sudo service ntp... to sudo service ntpd....

                  – rinogo
                  Jan 27 '15 at 22:48












                • 3





                  Thanks. Still showing 1970 after this command (w/ sudo). Reading ntpd manpage, I am not sure how this forces an update?

                  – ysap
                  Feb 14 '13 at 18:42






                • 12





                  The "-q" option tells the NTP daemon to start up, set the time and immediately exit. The "-g" option allows it to correct for time differences larger then 1000 sec. For longer term, you should simply configure the NTP daemon to be running always.

                  – tgharold
                  Sep 9 '13 at 18:16






                • 28





                  This answer should go to the top, because it is correct: ntpdate is deprecated and installing it is a bad idea, because it conflicts with ntp. If the clock is way off, you need to do this manual step because otherwise ntp will not change your clock and will not tell you why.

                  – Liam
                  Feb 6 '14 at 21:11






                • 27





                  For me, sudo ntpd -gq does not exit! I'm on 14.10 and I have to CTRL+C to continue... or how long is it supposed to take?

                  – Yanick Rochon
                  Jan 27 '15 at 2:41







                • 4





                  FYI, on my system (CentOS 6.6), I needed to change the two instances of sudo service ntp... to sudo service ntpd....

                  – rinogo
                  Jan 27 '15 at 22:48







                3




                3





                Thanks. Still showing 1970 after this command (w/ sudo). Reading ntpd manpage, I am not sure how this forces an update?

                – ysap
                Feb 14 '13 at 18:42





                Thanks. Still showing 1970 after this command (w/ sudo). Reading ntpd manpage, I am not sure how this forces an update?

                – ysap
                Feb 14 '13 at 18:42




                12




                12





                The "-q" option tells the NTP daemon to start up, set the time and immediately exit. The "-g" option allows it to correct for time differences larger then 1000 sec. For longer term, you should simply configure the NTP daemon to be running always.

                – tgharold
                Sep 9 '13 at 18:16





                The "-q" option tells the NTP daemon to start up, set the time and immediately exit. The "-g" option allows it to correct for time differences larger then 1000 sec. For longer term, you should simply configure the NTP daemon to be running always.

                – tgharold
                Sep 9 '13 at 18:16




                28




                28





                This answer should go to the top, because it is correct: ntpdate is deprecated and installing it is a bad idea, because it conflicts with ntp. If the clock is way off, you need to do this manual step because otherwise ntp will not change your clock and will not tell you why.

                – Liam
                Feb 6 '14 at 21:11





                This answer should go to the top, because it is correct: ntpdate is deprecated and installing it is a bad idea, because it conflicts with ntp. If the clock is way off, you need to do this manual step because otherwise ntp will not change your clock and will not tell you why.

                – Liam
                Feb 6 '14 at 21:11




                27




                27





                For me, sudo ntpd -gq does not exit! I'm on 14.10 and I have to CTRL+C to continue... or how long is it supposed to take?

                – Yanick Rochon
                Jan 27 '15 at 2:41






                For me, sudo ntpd -gq does not exit! I'm on 14.10 and I have to CTRL+C to continue... or how long is it supposed to take?

                – Yanick Rochon
                Jan 27 '15 at 2:41





                4




                4





                FYI, on my system (CentOS 6.6), I needed to change the two instances of sudo service ntp... to sudo service ntpd....

                – rinogo
                Jan 27 '15 at 22:48





                FYI, on my system (CentOS 6.6), I needed to change the two instances of sudo service ntp... to sudo service ntpd....

                – rinogo
                Jan 27 '15 at 22:48











                54














                Use sntp to set the time immediately. For example:



                sudo sntp -s 24.56.178.140


                The numbers after -s can be any ntp time server, that one is NIST in Ft. Collins, Colorado.






                share|improve this answer


















                • 1





                  That worked! +1

                  – CappY
                  Mar 23 '15 at 15:30






                • 6





                  This worked when "sudo ntpd -gq" didn't.

                  – Matt White
                  Apr 29 '16 at 14:54











                • I don't know how many times I've come searching for this answer. Works every time.

                  – Chaos
                  Oct 12 '16 at 4:45






                • 1





                  unable to locate package sntp ?

                  – temple
                  Apr 5 '17 at 17:54






                • 1





                  apt-get install sntp / yum install sntp (yes it works on CentOS,RedHat,fedore too)

                  – ndemou
                  Dec 5 '17 at 7:40















                54














                Use sntp to set the time immediately. For example:



                sudo sntp -s 24.56.178.140


                The numbers after -s can be any ntp time server, that one is NIST in Ft. Collins, Colorado.






                share|improve this answer


















                • 1





                  That worked! +1

                  – CappY
                  Mar 23 '15 at 15:30






                • 6





                  This worked when "sudo ntpd -gq" didn't.

                  – Matt White
                  Apr 29 '16 at 14:54











                • I don't know how many times I've come searching for this answer. Works every time.

                  – Chaos
                  Oct 12 '16 at 4:45






                • 1





                  unable to locate package sntp ?

                  – temple
                  Apr 5 '17 at 17:54






                • 1





                  apt-get install sntp / yum install sntp (yes it works on CentOS,RedHat,fedore too)

                  – ndemou
                  Dec 5 '17 at 7:40













                54












                54








                54







                Use sntp to set the time immediately. For example:



                sudo sntp -s 24.56.178.140


                The numbers after -s can be any ntp time server, that one is NIST in Ft. Collins, Colorado.






                share|improve this answer













                Use sntp to set the time immediately. For example:



                sudo sntp -s 24.56.178.140


                The numbers after -s can be any ntp time server, that one is NIST in Ft. Collins, Colorado.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 8 '13 at 1:00









                GuestGuest

                54142




                54142







                • 1





                  That worked! +1

                  – CappY
                  Mar 23 '15 at 15:30






                • 6





                  This worked when "sudo ntpd -gq" didn't.

                  – Matt White
                  Apr 29 '16 at 14:54











                • I don't know how many times I've come searching for this answer. Works every time.

                  – Chaos
                  Oct 12 '16 at 4:45






                • 1





                  unable to locate package sntp ?

                  – temple
                  Apr 5 '17 at 17:54






                • 1





                  apt-get install sntp / yum install sntp (yes it works on CentOS,RedHat,fedore too)

                  – ndemou
                  Dec 5 '17 at 7:40












                • 1





                  That worked! +1

                  – CappY
                  Mar 23 '15 at 15:30






                • 6





                  This worked when "sudo ntpd -gq" didn't.

                  – Matt White
                  Apr 29 '16 at 14:54











                • I don't know how many times I've come searching for this answer. Works every time.

                  – Chaos
                  Oct 12 '16 at 4:45






                • 1





                  unable to locate package sntp ?

                  – temple
                  Apr 5 '17 at 17:54






                • 1





                  apt-get install sntp / yum install sntp (yes it works on CentOS,RedHat,fedore too)

                  – ndemou
                  Dec 5 '17 at 7:40







                1




                1





                That worked! +1

                – CappY
                Mar 23 '15 at 15:30





                That worked! +1

                – CappY
                Mar 23 '15 at 15:30




                6




                6





                This worked when "sudo ntpd -gq" didn't.

                – Matt White
                Apr 29 '16 at 14:54





                This worked when "sudo ntpd -gq" didn't.

                – Matt White
                Apr 29 '16 at 14:54













                I don't know how many times I've come searching for this answer. Works every time.

                – Chaos
                Oct 12 '16 at 4:45





                I don't know how many times I've come searching for this answer. Works every time.

                – Chaos
                Oct 12 '16 at 4:45




                1




                1





                unable to locate package sntp ?

                – temple
                Apr 5 '17 at 17:54





                unable to locate package sntp ?

                – temple
                Apr 5 '17 at 17:54




                1




                1





                apt-get install sntp / yum install sntp (yes it works on CentOS,RedHat,fedore too)

                – ndemou
                Dec 5 '17 at 7:40





                apt-get install sntp / yum install sntp (yes it works on CentOS,RedHat,fedore too)

                – ndemou
                Dec 5 '17 at 7:40











                39














                As others have pointed out the best solution is to instruct ntpd to ignore the panic threshold, which is 1000 seconds by default. You can configure the panic threshold in one of two ways:



                • edit /etc/default/ntp and ensure that the -g option is present.

                • edit /etc/ntp.conf and place tinker panic 0 at the top

                So far this is essentially what others have recommended however there is one more step I think you should take. Install the fake-hwclock program:



                # apt-get install fake-hwclock


                fake-hwclock: Save/restore system clock on machines without working RTC hardware

                Some machines don't have a working realtime clock (RTC) unit, or no
                driver for the hardware that does exist. fake-hwclock is a simple set
                of scripts to save the kernel's current clock periodically (including
                at shutdown) and restore it at boot so that the system clock keeps at
                least close to realtime. This will stop some of the problems that may
                be caused by a system believing it has travelled in time back to
                1970, such as needing to perform filesystem checks at every boot.

                On top of this, use of NTP is still recommended to deal with the fake
                clock "drifting" while the hardware is halted or rebooting.


                With fake-hwclock installed your machine will not start up thinking it is 1970 all over again. When your machine boots up it will set its clock to the timestamp fake-hwclock wrote during the last reboot/shutdown. This means you can have a somewhat correct clock in case there are network issues when you boot up.






                share|improve this answer


















                • 1





                  -g seemed to do nothing for me (at the command line, I don't have /etc/default/ntp), but adding tinker panic 0 to ntp.conf worked

                  – Dave Cousineau
                  Aug 10 '17 at 1:36











                • @Sahuagin I don't know what to tell you other than you have a nonstandard ntp package. /etc/default/ntp is part of the package from Ubuntu: packages.ubuntu.com/xenial/amd64/ntp/filelist and -g has been an option for as long as I can remember.

                  – dfc
                  Aug 10 '17 at 1:52











                • sorry, I guess I'm not actually on Ubuntu and should have thought a little more before commenting. tinker panic 0 definitely seems to have worked though.

                  – Dave Cousineau
                  Aug 10 '17 at 20:21















                39














                As others have pointed out the best solution is to instruct ntpd to ignore the panic threshold, which is 1000 seconds by default. You can configure the panic threshold in one of two ways:



                • edit /etc/default/ntp and ensure that the -g option is present.

                • edit /etc/ntp.conf and place tinker panic 0 at the top

                So far this is essentially what others have recommended however there is one more step I think you should take. Install the fake-hwclock program:



                # apt-get install fake-hwclock


                fake-hwclock: Save/restore system clock on machines without working RTC hardware

                Some machines don't have a working realtime clock (RTC) unit, or no
                driver for the hardware that does exist. fake-hwclock is a simple set
                of scripts to save the kernel's current clock periodically (including
                at shutdown) and restore it at boot so that the system clock keeps at
                least close to realtime. This will stop some of the problems that may
                be caused by a system believing it has travelled in time back to
                1970, such as needing to perform filesystem checks at every boot.

                On top of this, use of NTP is still recommended to deal with the fake
                clock "drifting" while the hardware is halted or rebooting.


                With fake-hwclock installed your machine will not start up thinking it is 1970 all over again. When your machine boots up it will set its clock to the timestamp fake-hwclock wrote during the last reboot/shutdown. This means you can have a somewhat correct clock in case there are network issues when you boot up.






                share|improve this answer


















                • 1





                  -g seemed to do nothing for me (at the command line, I don't have /etc/default/ntp), but adding tinker panic 0 to ntp.conf worked

                  – Dave Cousineau
                  Aug 10 '17 at 1:36











                • @Sahuagin I don't know what to tell you other than you have a nonstandard ntp package. /etc/default/ntp is part of the package from Ubuntu: packages.ubuntu.com/xenial/amd64/ntp/filelist and -g has been an option for as long as I can remember.

                  – dfc
                  Aug 10 '17 at 1:52











                • sorry, I guess I'm not actually on Ubuntu and should have thought a little more before commenting. tinker panic 0 definitely seems to have worked though.

                  – Dave Cousineau
                  Aug 10 '17 at 20:21













                39












                39








                39







                As others have pointed out the best solution is to instruct ntpd to ignore the panic threshold, which is 1000 seconds by default. You can configure the panic threshold in one of two ways:



                • edit /etc/default/ntp and ensure that the -g option is present.

                • edit /etc/ntp.conf and place tinker panic 0 at the top

                So far this is essentially what others have recommended however there is one more step I think you should take. Install the fake-hwclock program:



                # apt-get install fake-hwclock


                fake-hwclock: Save/restore system clock on machines without working RTC hardware

                Some machines don't have a working realtime clock (RTC) unit, or no
                driver for the hardware that does exist. fake-hwclock is a simple set
                of scripts to save the kernel's current clock periodically (including
                at shutdown) and restore it at boot so that the system clock keeps at
                least close to realtime. This will stop some of the problems that may
                be caused by a system believing it has travelled in time back to
                1970, such as needing to perform filesystem checks at every boot.

                On top of this, use of NTP is still recommended to deal with the fake
                clock "drifting" while the hardware is halted or rebooting.


                With fake-hwclock installed your machine will not start up thinking it is 1970 all over again. When your machine boots up it will set its clock to the timestamp fake-hwclock wrote during the last reboot/shutdown. This means you can have a somewhat correct clock in case there are network issues when you boot up.






                share|improve this answer













                As others have pointed out the best solution is to instruct ntpd to ignore the panic threshold, which is 1000 seconds by default. You can configure the panic threshold in one of two ways:



                • edit /etc/default/ntp and ensure that the -g option is present.

                • edit /etc/ntp.conf and place tinker panic 0 at the top

                So far this is essentially what others have recommended however there is one more step I think you should take. Install the fake-hwclock program:



                # apt-get install fake-hwclock


                fake-hwclock: Save/restore system clock on machines without working RTC hardware

                Some machines don't have a working realtime clock (RTC) unit, or no
                driver for the hardware that does exist. fake-hwclock is a simple set
                of scripts to save the kernel's current clock periodically (including
                at shutdown) and restore it at boot so that the system clock keeps at
                least close to realtime. This will stop some of the problems that may
                be caused by a system believing it has travelled in time back to
                1970, such as needing to perform filesystem checks at every boot.

                On top of this, use of NTP is still recommended to deal with the fake
                clock "drifting" while the hardware is halted or rebooting.


                With fake-hwclock installed your machine will not start up thinking it is 1970 all over again. When your machine boots up it will set its clock to the timestamp fake-hwclock wrote during the last reboot/shutdown. This means you can have a somewhat correct clock in case there are network issues when you boot up.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Apr 3 '14 at 22:11









                dfcdfc

                1,2791111




                1,2791111







                • 1





                  -g seemed to do nothing for me (at the command line, I don't have /etc/default/ntp), but adding tinker panic 0 to ntp.conf worked

                  – Dave Cousineau
                  Aug 10 '17 at 1:36











                • @Sahuagin I don't know what to tell you other than you have a nonstandard ntp package. /etc/default/ntp is part of the package from Ubuntu: packages.ubuntu.com/xenial/amd64/ntp/filelist and -g has been an option for as long as I can remember.

                  – dfc
                  Aug 10 '17 at 1:52











                • sorry, I guess I'm not actually on Ubuntu and should have thought a little more before commenting. tinker panic 0 definitely seems to have worked though.

                  – Dave Cousineau
                  Aug 10 '17 at 20:21












                • 1





                  -g seemed to do nothing for me (at the command line, I don't have /etc/default/ntp), but adding tinker panic 0 to ntp.conf worked

                  – Dave Cousineau
                  Aug 10 '17 at 1:36











                • @Sahuagin I don't know what to tell you other than you have a nonstandard ntp package. /etc/default/ntp is part of the package from Ubuntu: packages.ubuntu.com/xenial/amd64/ntp/filelist and -g has been an option for as long as I can remember.

                  – dfc
                  Aug 10 '17 at 1:52











                • sorry, I guess I'm not actually on Ubuntu and should have thought a little more before commenting. tinker panic 0 definitely seems to have worked though.

                  – Dave Cousineau
                  Aug 10 '17 at 20:21







                1




                1





                -g seemed to do nothing for me (at the command line, I don't have /etc/default/ntp), but adding tinker panic 0 to ntp.conf worked

                – Dave Cousineau
                Aug 10 '17 at 1:36





                -g seemed to do nothing for me (at the command line, I don't have /etc/default/ntp), but adding tinker panic 0 to ntp.conf worked

                – Dave Cousineau
                Aug 10 '17 at 1:36













                @Sahuagin I don't know what to tell you other than you have a nonstandard ntp package. /etc/default/ntp is part of the package from Ubuntu: packages.ubuntu.com/xenial/amd64/ntp/filelist and -g has been an option for as long as I can remember.

                – dfc
                Aug 10 '17 at 1:52





                @Sahuagin I don't know what to tell you other than you have a nonstandard ntp package. /etc/default/ntp is part of the package from Ubuntu: packages.ubuntu.com/xenial/amd64/ntp/filelist and -g has been an option for as long as I can remember.

                – dfc
                Aug 10 '17 at 1:52













                sorry, I guess I'm not actually on Ubuntu and should have thought a little more before commenting. tinker panic 0 definitely seems to have worked though.

                – Dave Cousineau
                Aug 10 '17 at 20:21





                sorry, I guess I'm not actually on Ubuntu and should have thought a little more before commenting. tinker panic 0 definitely seems to have worked though.

                – Dave Cousineau
                Aug 10 '17 at 20:21











                12














                ntpdate is a program different from the net dameon. NTPDate is probably erroring out on boot because ntpd is running on that socket.



                From the command line, run



                # sudo service ntp stop ; sudo ntpdate -s time.nist.gov ; sudo service ntp start


                You could also uninstall ntpd all together (apt-get remove ntp) and add a cron script to use ntpdate every hour or so.



                UPDATE



                ntp service probably won't have meaningful value for you on this system, so remove that first.



                # sudo apt-get remove ntp


                Now add the command:



                ntpdate -sb time.nist.gov


                to /etc/rclocal



                Reboot. Should be good at that point.






                share|improve this answer

























                • answer updated.

                  – Stephan
                  Feb 14 '13 at 19:53






                • 1





                  Isn't ntpdate being phased out or something? Also, If I understand this correctly, the service runs and maintains the sync of the local clock to the server's clock - so the drift is bound. If you remove ntp and run ntpdate once, won't it be affected by clock drifting when the machine is on for extended periods?

                  – ysap
                  Feb 14 '13 at 21:07












                • Stephan, please see update #2 to the question.

                  – ysap
                  Feb 15 '13 at 21:42






                • 3





                  Yes, ntpdate is being phased out. Use of "ntpd -q" is preferred (both variants require that ntpd be stopped first).

                  – tgharold
                  Sep 9 '13 at 18:17















                12














                ntpdate is a program different from the net dameon. NTPDate is probably erroring out on boot because ntpd is running on that socket.



                From the command line, run



                # sudo service ntp stop ; sudo ntpdate -s time.nist.gov ; sudo service ntp start


                You could also uninstall ntpd all together (apt-get remove ntp) and add a cron script to use ntpdate every hour or so.



                UPDATE



                ntp service probably won't have meaningful value for you on this system, so remove that first.



                # sudo apt-get remove ntp


                Now add the command:



                ntpdate -sb time.nist.gov


                to /etc/rclocal



                Reboot. Should be good at that point.






                share|improve this answer

























                • answer updated.

                  – Stephan
                  Feb 14 '13 at 19:53






                • 1





                  Isn't ntpdate being phased out or something? Also, If I understand this correctly, the service runs and maintains the sync of the local clock to the server's clock - so the drift is bound. If you remove ntp and run ntpdate once, won't it be affected by clock drifting when the machine is on for extended periods?

                  – ysap
                  Feb 14 '13 at 21:07












                • Stephan, please see update #2 to the question.

                  – ysap
                  Feb 15 '13 at 21:42






                • 3





                  Yes, ntpdate is being phased out. Use of "ntpd -q" is preferred (both variants require that ntpd be stopped first).

                  – tgharold
                  Sep 9 '13 at 18:17













                12












                12








                12







                ntpdate is a program different from the net dameon. NTPDate is probably erroring out on boot because ntpd is running on that socket.



                From the command line, run



                # sudo service ntp stop ; sudo ntpdate -s time.nist.gov ; sudo service ntp start


                You could also uninstall ntpd all together (apt-get remove ntp) and add a cron script to use ntpdate every hour or so.



                UPDATE



                ntp service probably won't have meaningful value for you on this system, so remove that first.



                # sudo apt-get remove ntp


                Now add the command:



                ntpdate -sb time.nist.gov


                to /etc/rclocal



                Reboot. Should be good at that point.






                share|improve this answer















                ntpdate is a program different from the net dameon. NTPDate is probably erroring out on boot because ntpd is running on that socket.



                From the command line, run



                # sudo service ntp stop ; sudo ntpdate -s time.nist.gov ; sudo service ntp start


                You could also uninstall ntpd all together (apt-get remove ntp) and add a cron script to use ntpdate every hour or so.



                UPDATE



                ntp service probably won't have meaningful value for you on this system, so remove that first.



                # sudo apt-get remove ntp


                Now add the command:



                ntpdate -sb time.nist.gov


                to /etc/rclocal



                Reboot. Should be good at that point.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Feb 14 '13 at 19:52

























                answered Feb 13 '13 at 23:07









                StephanStephan

                56126




                56126












                • answer updated.

                  – Stephan
                  Feb 14 '13 at 19:53






                • 1





                  Isn't ntpdate being phased out or something? Also, If I understand this correctly, the service runs and maintains the sync of the local clock to the server's clock - so the drift is bound. If you remove ntp and run ntpdate once, won't it be affected by clock drifting when the machine is on for extended periods?

                  – ysap
                  Feb 14 '13 at 21:07












                • Stephan, please see update #2 to the question.

                  – ysap
                  Feb 15 '13 at 21:42






                • 3





                  Yes, ntpdate is being phased out. Use of "ntpd -q" is preferred (both variants require that ntpd be stopped first).

                  – tgharold
                  Sep 9 '13 at 18:17

















                • answer updated.

                  – Stephan
                  Feb 14 '13 at 19:53






                • 1





                  Isn't ntpdate being phased out or something? Also, If I understand this correctly, the service runs and maintains the sync of the local clock to the server's clock - so the drift is bound. If you remove ntp and run ntpdate once, won't it be affected by clock drifting when the machine is on for extended periods?

                  – ysap
                  Feb 14 '13 at 21:07












                • Stephan, please see update #2 to the question.

                  – ysap
                  Feb 15 '13 at 21:42






                • 3





                  Yes, ntpdate is being phased out. Use of "ntpd -q" is preferred (both variants require that ntpd be stopped first).

                  – tgharold
                  Sep 9 '13 at 18:17
















                answer updated.

                – Stephan
                Feb 14 '13 at 19:53





                answer updated.

                – Stephan
                Feb 14 '13 at 19:53




                1




                1





                Isn't ntpdate being phased out or something? Also, If I understand this correctly, the service runs and maintains the sync of the local clock to the server's clock - so the drift is bound. If you remove ntp and run ntpdate once, won't it be affected by clock drifting when the machine is on for extended periods?

                – ysap
                Feb 14 '13 at 21:07






                Isn't ntpdate being phased out or something? Also, If I understand this correctly, the service runs and maintains the sync of the local clock to the server's clock - so the drift is bound. If you remove ntp and run ntpdate once, won't it be affected by clock drifting when the machine is on for extended periods?

                – ysap
                Feb 14 '13 at 21:07














                Stephan, please see update #2 to the question.

                – ysap
                Feb 15 '13 at 21:42





                Stephan, please see update #2 to the question.

                – ysap
                Feb 15 '13 at 21:42




                3




                3





                Yes, ntpdate is being phased out. Use of "ntpd -q" is preferred (both variants require that ntpd be stopped first).

                – tgharold
                Sep 9 '13 at 18:17





                Yes, ntpdate is being phased out. Use of "ntpd -q" is preferred (both variants require that ntpd be stopped first).

                – tgharold
                Sep 9 '13 at 18:17











                10














                rdate -s tick.greyware.com


                if all you want to do is set the clock once, simple






                share|improve this answer























                • Thanks. I don't currently have the system to check this command, but if you follow the discussion in the question and the accepted answer, you'll see that the problem was actually network unavailability at the time of running the clock update command.

                  – ysap
                  Feb 27 '15 at 0:57











                • This fixed a time sync issue on my Raspberry Pi. Thank you.

                  – Oliver Spryn
                  Feb 15 '17 at 16:58















                10














                rdate -s tick.greyware.com


                if all you want to do is set the clock once, simple






                share|improve this answer























                • Thanks. I don't currently have the system to check this command, but if you follow the discussion in the question and the accepted answer, you'll see that the problem was actually network unavailability at the time of running the clock update command.

                  – ysap
                  Feb 27 '15 at 0:57











                • This fixed a time sync issue on my Raspberry Pi. Thank you.

                  – Oliver Spryn
                  Feb 15 '17 at 16:58













                10












                10








                10







                rdate -s tick.greyware.com


                if all you want to do is set the clock once, simple






                share|improve this answer













                rdate -s tick.greyware.com


                if all you want to do is set the clock once, simple







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 26 '15 at 22:57









                batflapsbatflaps

                20122




                20122












                • Thanks. I don't currently have the system to check this command, but if you follow the discussion in the question and the accepted answer, you'll see that the problem was actually network unavailability at the time of running the clock update command.

                  – ysap
                  Feb 27 '15 at 0:57











                • This fixed a time sync issue on my Raspberry Pi. Thank you.

                  – Oliver Spryn
                  Feb 15 '17 at 16:58

















                • Thanks. I don't currently have the system to check this command, but if you follow the discussion in the question and the accepted answer, you'll see that the problem was actually network unavailability at the time of running the clock update command.

                  – ysap
                  Feb 27 '15 at 0:57











                • This fixed a time sync issue on my Raspberry Pi. Thank you.

                  – Oliver Spryn
                  Feb 15 '17 at 16:58
















                Thanks. I don't currently have the system to check this command, but if you follow the discussion in the question and the accepted answer, you'll see that the problem was actually network unavailability at the time of running the clock update command.

                – ysap
                Feb 27 '15 at 0:57





                Thanks. I don't currently have the system to check this command, but if you follow the discussion in the question and the accepted answer, you'll see that the problem was actually network unavailability at the time of running the clock update command.

                – ysap
                Feb 27 '15 at 0:57













                This fixed a time sync issue on my Raspberry Pi. Thank you.

                – Oliver Spryn
                Feb 15 '17 at 16:58





                This fixed a time sync issue on my Raspberry Pi. Thank you.

                – Oliver Spryn
                Feb 15 '17 at 16:58











                7














                The correct way to do this on a Debian / Mint / Ubuntu (or other Debian derivative) system is to have the line



                NTPD_OPTS="-g"


                in the file



                /etc/default/ntp


                This ensures that when ntpd is started from the /etc/init.d/ntp script, it runs with the "-g" option, viz



                 start-stop-daemon --start --quiet --oknodo --pidfile /var/run/ntpd.pid --startas /usr/sbin/ntpd -- -p /var/run/ntpd.pid -g -u 124:128


                to allow ntpd to correct the system time when it is more than 1000 s out, eg when the system time is January 1st 1970 on startup because there is no hardware RTC.






                share|improve this answer























                • I have that already, but it still says 3AM in NY, when it should be 11pm.

                  – chovy
                  Jul 6 '14 at 3:07











                • I also already had exactly that line in /etc/default/ntp, but time wasn't synchronized.

                  – Dawid Ferenczy
                  Nov 10 '14 at 18:15















                7














                The correct way to do this on a Debian / Mint / Ubuntu (or other Debian derivative) system is to have the line



                NTPD_OPTS="-g"


                in the file



                /etc/default/ntp


                This ensures that when ntpd is started from the /etc/init.d/ntp script, it runs with the "-g" option, viz



                 start-stop-daemon --start --quiet --oknodo --pidfile /var/run/ntpd.pid --startas /usr/sbin/ntpd -- -p /var/run/ntpd.pid -g -u 124:128


                to allow ntpd to correct the system time when it is more than 1000 s out, eg when the system time is January 1st 1970 on startup because there is no hardware RTC.






                share|improve this answer























                • I have that already, but it still says 3AM in NY, when it should be 11pm.

                  – chovy
                  Jul 6 '14 at 3:07











                • I also already had exactly that line in /etc/default/ntp, but time wasn't synchronized.

                  – Dawid Ferenczy
                  Nov 10 '14 at 18:15













                7












                7








                7







                The correct way to do this on a Debian / Mint / Ubuntu (or other Debian derivative) system is to have the line



                NTPD_OPTS="-g"


                in the file



                /etc/default/ntp


                This ensures that when ntpd is started from the /etc/init.d/ntp script, it runs with the "-g" option, viz



                 start-stop-daemon --start --quiet --oknodo --pidfile /var/run/ntpd.pid --startas /usr/sbin/ntpd -- -p /var/run/ntpd.pid -g -u 124:128


                to allow ntpd to correct the system time when it is more than 1000 s out, eg when the system time is January 1st 1970 on startup because there is no hardware RTC.






                share|improve this answer













                The correct way to do this on a Debian / Mint / Ubuntu (or other Debian derivative) system is to have the line



                NTPD_OPTS="-g"


                in the file



                /etc/default/ntp


                This ensures that when ntpd is started from the /etc/init.d/ntp script, it runs with the "-g" option, viz



                 start-stop-daemon --start --quiet --oknodo --pidfile /var/run/ntpd.pid --startas /usr/sbin/ntpd -- -p /var/run/ntpd.pid -g -u 124:128


                to allow ntpd to correct the system time when it is more than 1000 s out, eg when the system time is January 1st 1970 on startup because there is no hardware RTC.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Apr 3 '14 at 11:20









                J G MillerJ G Miller

                42646




                42646












                • I have that already, but it still says 3AM in NY, when it should be 11pm.

                  – chovy
                  Jul 6 '14 at 3:07











                • I also already had exactly that line in /etc/default/ntp, but time wasn't synchronized.

                  – Dawid Ferenczy
                  Nov 10 '14 at 18:15

















                • I have that already, but it still says 3AM in NY, when it should be 11pm.

                  – chovy
                  Jul 6 '14 at 3:07











                • I also already had exactly that line in /etc/default/ntp, but time wasn't synchronized.

                  – Dawid Ferenczy
                  Nov 10 '14 at 18:15
















                I have that already, but it still says 3AM in NY, when it should be 11pm.

                – chovy
                Jul 6 '14 at 3:07





                I have that already, but it still says 3AM in NY, when it should be 11pm.

                – chovy
                Jul 6 '14 at 3:07













                I also already had exactly that line in /etc/default/ntp, but time wasn't synchronized.

                – Dawid Ferenczy
                Nov 10 '14 at 18:15





                I also already had exactly that line in /etc/default/ntp, but time wasn't synchronized.

                – Dawid Ferenczy
                Nov 10 '14 at 18:15











                4














                Try using the -b option to step the time.






                share|improve this answer


















                • 2





                  When trying from command line, I get the following response: 1 Jan 00:04:11 ntpdate[2226]: the NTP socket is in use, exiting . However, I think that I tried this before in rc.local but it did not help.

                  – ysap
                  Feb 13 '13 at 22:28







                • 2





                  You need to stop the ntp service first before you can run ntpdate -b <ipaddress>

                  – Wim Deblauwe
                  Nov 26 '14 at 13:02















                4














                Try using the -b option to step the time.






                share|improve this answer


















                • 2





                  When trying from command line, I get the following response: 1 Jan 00:04:11 ntpdate[2226]: the NTP socket is in use, exiting . However, I think that I tried this before in rc.local but it did not help.

                  – ysap
                  Feb 13 '13 at 22:28







                • 2





                  You need to stop the ntp service first before you can run ntpdate -b <ipaddress>

                  – Wim Deblauwe
                  Nov 26 '14 at 13:02













                4












                4








                4







                Try using the -b option to step the time.






                share|improve this answer













                Try using the -b option to step the time.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 13 '13 at 22:18









                Cry HavokCry Havok

                1,28888




                1,28888







                • 2





                  When trying from command line, I get the following response: 1 Jan 00:04:11 ntpdate[2226]: the NTP socket is in use, exiting . However, I think that I tried this before in rc.local but it did not help.

                  – ysap
                  Feb 13 '13 at 22:28







                • 2





                  You need to stop the ntp service first before you can run ntpdate -b <ipaddress>

                  – Wim Deblauwe
                  Nov 26 '14 at 13:02












                • 2





                  When trying from command line, I get the following response: 1 Jan 00:04:11 ntpdate[2226]: the NTP socket is in use, exiting . However, I think that I tried this before in rc.local but it did not help.

                  – ysap
                  Feb 13 '13 at 22:28







                • 2





                  You need to stop the ntp service first before you can run ntpdate -b <ipaddress>

                  – Wim Deblauwe
                  Nov 26 '14 at 13:02







                2




                2





                When trying from command line, I get the following response: 1 Jan 00:04:11 ntpdate[2226]: the NTP socket is in use, exiting . However, I think that I tried this before in rc.local but it did not help.

                – ysap
                Feb 13 '13 at 22:28






                When trying from command line, I get the following response: 1 Jan 00:04:11 ntpdate[2226]: the NTP socket is in use, exiting . However, I think that I tried this before in rc.local but it did not help.

                – ysap
                Feb 13 '13 at 22:28





                2




                2





                You need to stop the ntp service first before you can run ntpdate -b <ipaddress>

                – Wim Deblauwe
                Nov 26 '14 at 13:02





                You need to stop the ntp service first before you can run ntpdate -b <ipaddress>

                – Wim Deblauwe
                Nov 26 '14 at 13:02











                4














                tlsdate sets the local clock by securely connecting with TLS to remote servers and extracting the remote time out of the secure handshake. Unlike
                ntpdate, tlsdate uses TCP, for instance connecting to a remote HTTPS or TLS
                enabled service, and provides some protection against adversaries that try to
                feed you malicious time information.



                $ tlsdate -V -n -H encrypted.google.com





                share|improve this answer





























                  4














                  tlsdate sets the local clock by securely connecting with TLS to remote servers and extracting the remote time out of the secure handshake. Unlike
                  ntpdate, tlsdate uses TCP, for instance connecting to a remote HTTPS or TLS
                  enabled service, and provides some protection against adversaries that try to
                  feed you malicious time information.



                  $ tlsdate -V -n -H encrypted.google.com





                  share|improve this answer



























                    4












                    4








                    4







                    tlsdate sets the local clock by securely connecting with TLS to remote servers and extracting the remote time out of the secure handshake. Unlike
                    ntpdate, tlsdate uses TCP, for instance connecting to a remote HTTPS or TLS
                    enabled service, and provides some protection against adversaries that try to
                    feed you malicious time information.



                    $ tlsdate -V -n -H encrypted.google.com





                    share|improve this answer















                    tlsdate sets the local clock by securely connecting with TLS to remote servers and extracting the remote time out of the secure handshake. Unlike
                    ntpdate, tlsdate uses TCP, for instance connecting to a remote HTTPS or TLS
                    enabled service, and provides some protection against adversaries that try to
                    feed you malicious time information.



                    $ tlsdate -V -n -H encrypted.google.com






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Jul 31 '18 at 10:23









                    slm

                    1,76011824




                    1,76011824










                    answered Feb 23 '16 at 11:52









                    KokizzuKokizzu

                    220311




                    220311





















                        4














                        Use timedatectl (systemd service unit) to set the time. ntp is deprecated.



                        sudo systemctl restart systemd-timesyncd.service


                        You can check the time was updated reading the logs with journalctl -xe | tail



                        Reference



                        • Ubuntu Server documentation

                        • Freedesktop

                        • man timesyncd.conf





                        share|improve this answer





























                          4














                          Use timedatectl (systemd service unit) to set the time. ntp is deprecated.



                          sudo systemctl restart systemd-timesyncd.service


                          You can check the time was updated reading the logs with journalctl -xe | tail



                          Reference



                          • Ubuntu Server documentation

                          • Freedesktop

                          • man timesyncd.conf





                          share|improve this answer



























                            4












                            4








                            4







                            Use timedatectl (systemd service unit) to set the time. ntp is deprecated.



                            sudo systemctl restart systemd-timesyncd.service


                            You can check the time was updated reading the logs with journalctl -xe | tail



                            Reference



                            • Ubuntu Server documentation

                            • Freedesktop

                            • man timesyncd.conf





                            share|improve this answer















                            Use timedatectl (systemd service unit) to set the time. ntp is deprecated.



                            sudo systemctl restart systemd-timesyncd.service


                            You can check the time was updated reading the logs with journalctl -xe | tail



                            Reference



                            • Ubuntu Server documentation

                            • Freedesktop

                            • man timesyncd.conf






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited 14 mins ago









                            Pablo Bianchi

                            3,04521536




                            3,04521536










                            answered Nov 29 '16 at 8:57









                            xiaoyifangxiaoyifang

                            1672




                            1672





















                                2














                                Well,



                                I am running a raspbian (debian wheezy) on my raspberry pi, which doesn't have the hwclock. I found it handy to write a little script and run it after my internet interface is up, so that I am sure that the moment the network becomes available, the clock gets updated.



                                First check that you have the ntpdate package by running



                                sudo apt-get update
                                sudo apt-get install ntpdate


                                You need to add the following into your /etc/network/interfaces (surely eth0 here is just an example):



                                auto eth0
                                iface eth0 inet dhcp
                                post-up /usr/local/sbin/update-time.sh


                                And create the following script in /usr/local/sbin/update-time.sh (don't forget to make it executable by chmod):



                                #!/bin/bash
                                # This script checks if the ntp process is running, stops it, updates the system time, starts it again

                                ps cax | grep -c ntpd > /dev/null
                                onoff=$?
                                if [ "$onoff" -gt 0 ]; then
                                echo "stopping ntpd..."
                                service ntp stop
                                echo "ntpd stopped"
                                else
                                echo "ntpd not running, ready to update the date"
                                fi


                                isinstalled=$(dpkg-query -l | grep -c ntpdate)
                                if [ "$isinstalled" -gt 0 ]; then
                                ntpdate -t 3 -s ntp4.stratum2.ru
                                echo "date and time update executed"
                                else
                                echo "ntpdate package not installed, can't update using ntp"
                                fi

                                echo "restarting ntpd..."
                                service ntp start
                                echo "ntpd running"
                                echo "printing current date and time:"
                                date

                                exit





                                share|improve this answer



























                                  2














                                  Well,



                                  I am running a raspbian (debian wheezy) on my raspberry pi, which doesn't have the hwclock. I found it handy to write a little script and run it after my internet interface is up, so that I am sure that the moment the network becomes available, the clock gets updated.



                                  First check that you have the ntpdate package by running



                                  sudo apt-get update
                                  sudo apt-get install ntpdate


                                  You need to add the following into your /etc/network/interfaces (surely eth0 here is just an example):



                                  auto eth0
                                  iface eth0 inet dhcp
                                  post-up /usr/local/sbin/update-time.sh


                                  And create the following script in /usr/local/sbin/update-time.sh (don't forget to make it executable by chmod):



                                  #!/bin/bash
                                  # This script checks if the ntp process is running, stops it, updates the system time, starts it again

                                  ps cax | grep -c ntpd > /dev/null
                                  onoff=$?
                                  if [ "$onoff" -gt 0 ]; then
                                  echo "stopping ntpd..."
                                  service ntp stop
                                  echo "ntpd stopped"
                                  else
                                  echo "ntpd not running, ready to update the date"
                                  fi


                                  isinstalled=$(dpkg-query -l | grep -c ntpdate)
                                  if [ "$isinstalled" -gt 0 ]; then
                                  ntpdate -t 3 -s ntp4.stratum2.ru
                                  echo "date and time update executed"
                                  else
                                  echo "ntpdate package not installed, can't update using ntp"
                                  fi

                                  echo "restarting ntpd..."
                                  service ntp start
                                  echo "ntpd running"
                                  echo "printing current date and time:"
                                  date

                                  exit





                                  share|improve this answer

























                                    2












                                    2








                                    2







                                    Well,



                                    I am running a raspbian (debian wheezy) on my raspberry pi, which doesn't have the hwclock. I found it handy to write a little script and run it after my internet interface is up, so that I am sure that the moment the network becomes available, the clock gets updated.



                                    First check that you have the ntpdate package by running



                                    sudo apt-get update
                                    sudo apt-get install ntpdate


                                    You need to add the following into your /etc/network/interfaces (surely eth0 here is just an example):



                                    auto eth0
                                    iface eth0 inet dhcp
                                    post-up /usr/local/sbin/update-time.sh


                                    And create the following script in /usr/local/sbin/update-time.sh (don't forget to make it executable by chmod):



                                    #!/bin/bash
                                    # This script checks if the ntp process is running, stops it, updates the system time, starts it again

                                    ps cax | grep -c ntpd > /dev/null
                                    onoff=$?
                                    if [ "$onoff" -gt 0 ]; then
                                    echo "stopping ntpd..."
                                    service ntp stop
                                    echo "ntpd stopped"
                                    else
                                    echo "ntpd not running, ready to update the date"
                                    fi


                                    isinstalled=$(dpkg-query -l | grep -c ntpdate)
                                    if [ "$isinstalled" -gt 0 ]; then
                                    ntpdate -t 3 -s ntp4.stratum2.ru
                                    echo "date and time update executed"
                                    else
                                    echo "ntpdate package not installed, can't update using ntp"
                                    fi

                                    echo "restarting ntpd..."
                                    service ntp start
                                    echo "ntpd running"
                                    echo "printing current date and time:"
                                    date

                                    exit





                                    share|improve this answer













                                    Well,



                                    I am running a raspbian (debian wheezy) on my raspberry pi, which doesn't have the hwclock. I found it handy to write a little script and run it after my internet interface is up, so that I am sure that the moment the network becomes available, the clock gets updated.



                                    First check that you have the ntpdate package by running



                                    sudo apt-get update
                                    sudo apt-get install ntpdate


                                    You need to add the following into your /etc/network/interfaces (surely eth0 here is just an example):



                                    auto eth0
                                    iface eth0 inet dhcp
                                    post-up /usr/local/sbin/update-time.sh


                                    And create the following script in /usr/local/sbin/update-time.sh (don't forget to make it executable by chmod):



                                    #!/bin/bash
                                    # This script checks if the ntp process is running, stops it, updates the system time, starts it again

                                    ps cax | grep -c ntpd > /dev/null
                                    onoff=$?
                                    if [ "$onoff" -gt 0 ]; then
                                    echo "stopping ntpd..."
                                    service ntp stop
                                    echo "ntpd stopped"
                                    else
                                    echo "ntpd not running, ready to update the date"
                                    fi


                                    isinstalled=$(dpkg-query -l | grep -c ntpdate)
                                    if [ "$isinstalled" -gt 0 ]; then
                                    ntpdate -t 3 -s ntp4.stratum2.ru
                                    echo "date and time update executed"
                                    else
                                    echo "ntpdate package not installed, can't update using ntp"
                                    fi

                                    echo "restarting ntpd..."
                                    service ntp start
                                    echo "ntpd running"
                                    echo "printing current date and time:"
                                    date

                                    exit






                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Dec 12 '15 at 15:14









                                    art.shutterart.shutter

                                    211




                                    211





















                                        2














                                        Note that some current Ubuntu based systems don't even use the NTP service by default now. On my Linux Mint 19 (Ubuntu 18.04) machine, time is kept by systemd-timesyncd.



                                        So to get an up to date time after it has lost sync, I just run



                                        sudo systemctl restart systemd-timesyncd


                                        Since 15.04 Ubuntu uses systemd by default. Therefore critical systems like time are managed through systemd. To find what service your system is using run something like



                                        systemctl list-unit-files | grep -E 'ntp|timesyncd'


                                        For TechJS on 16.04 the service was ntp. For myself on Ubuntu 18.04 (Mint 19) the service is systemd-timesyncd. Interestingly, I logged into a 16.04 server I have and it uses systemd-timesyncd as well.






                                        share|improve this answer

























                                        • Thanks. It has been a long time since posting the question, and I don't have a system available for testing, but can you elaborate on how is your answer different from @TechJS , especially the command you proposed is slightly different.

                                          – ysap
                                          Nov 29 '18 at 17:37











                                        • Ha thanks. It was a response to you but also to anyone who in the future finds themselves here without more up to date information (like myself). I updated my answer to be more specific on how I reach my answer.

                                          – Aaron Chamberlain
                                          Nov 29 '18 at 18:52















                                        2














                                        Note that some current Ubuntu based systems don't even use the NTP service by default now. On my Linux Mint 19 (Ubuntu 18.04) machine, time is kept by systemd-timesyncd.



                                        So to get an up to date time after it has lost sync, I just run



                                        sudo systemctl restart systemd-timesyncd


                                        Since 15.04 Ubuntu uses systemd by default. Therefore critical systems like time are managed through systemd. To find what service your system is using run something like



                                        systemctl list-unit-files | grep -E 'ntp|timesyncd'


                                        For TechJS on 16.04 the service was ntp. For myself on Ubuntu 18.04 (Mint 19) the service is systemd-timesyncd. Interestingly, I logged into a 16.04 server I have and it uses systemd-timesyncd as well.






                                        share|improve this answer

























                                        • Thanks. It has been a long time since posting the question, and I don't have a system available for testing, but can you elaborate on how is your answer different from @TechJS , especially the command you proposed is slightly different.

                                          – ysap
                                          Nov 29 '18 at 17:37











                                        • Ha thanks. It was a response to you but also to anyone who in the future finds themselves here without more up to date information (like myself). I updated my answer to be more specific on how I reach my answer.

                                          – Aaron Chamberlain
                                          Nov 29 '18 at 18:52













                                        2












                                        2








                                        2







                                        Note that some current Ubuntu based systems don't even use the NTP service by default now. On my Linux Mint 19 (Ubuntu 18.04) machine, time is kept by systemd-timesyncd.



                                        So to get an up to date time after it has lost sync, I just run



                                        sudo systemctl restart systemd-timesyncd


                                        Since 15.04 Ubuntu uses systemd by default. Therefore critical systems like time are managed through systemd. To find what service your system is using run something like



                                        systemctl list-unit-files | grep -E 'ntp|timesyncd'


                                        For TechJS on 16.04 the service was ntp. For myself on Ubuntu 18.04 (Mint 19) the service is systemd-timesyncd. Interestingly, I logged into a 16.04 server I have and it uses systemd-timesyncd as well.






                                        share|improve this answer















                                        Note that some current Ubuntu based systems don't even use the NTP service by default now. On my Linux Mint 19 (Ubuntu 18.04) machine, time is kept by systemd-timesyncd.



                                        So to get an up to date time after it has lost sync, I just run



                                        sudo systemctl restart systemd-timesyncd


                                        Since 15.04 Ubuntu uses systemd by default. Therefore critical systems like time are managed through systemd. To find what service your system is using run something like



                                        systemctl list-unit-files | grep -E 'ntp|timesyncd'


                                        For TechJS on 16.04 the service was ntp. For myself on Ubuntu 18.04 (Mint 19) the service is systemd-timesyncd. Interestingly, I logged into a 16.04 server I have and it uses systemd-timesyncd as well.







                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited Nov 29 '18 at 19:00

























                                        answered Nov 29 '18 at 15:55









                                        Aaron ChamberlainAaron Chamberlain

                                        417




                                        417












                                        • Thanks. It has been a long time since posting the question, and I don't have a system available for testing, but can you elaborate on how is your answer different from @TechJS , especially the command you proposed is slightly different.

                                          – ysap
                                          Nov 29 '18 at 17:37











                                        • Ha thanks. It was a response to you but also to anyone who in the future finds themselves here without more up to date information (like myself). I updated my answer to be more specific on how I reach my answer.

                                          – Aaron Chamberlain
                                          Nov 29 '18 at 18:52

















                                        • Thanks. It has been a long time since posting the question, and I don't have a system available for testing, but can you elaborate on how is your answer different from @TechJS , especially the command you proposed is slightly different.

                                          – ysap
                                          Nov 29 '18 at 17:37











                                        • Ha thanks. It was a response to you but also to anyone who in the future finds themselves here without more up to date information (like myself). I updated my answer to be more specific on how I reach my answer.

                                          – Aaron Chamberlain
                                          Nov 29 '18 at 18:52
















                                        Thanks. It has been a long time since posting the question, and I don't have a system available for testing, but can you elaborate on how is your answer different from @TechJS , especially the command you proposed is slightly different.

                                        – ysap
                                        Nov 29 '18 at 17:37





                                        Thanks. It has been a long time since posting the question, and I don't have a system available for testing, but can you elaborate on how is your answer different from @TechJS , especially the command you proposed is slightly different.

                                        – ysap
                                        Nov 29 '18 at 17:37













                                        Ha thanks. It was a response to you but also to anyone who in the future finds themselves here without more up to date information (like myself). I updated my answer to be more specific on how I reach my answer.

                                        – Aaron Chamberlain
                                        Nov 29 '18 at 18:52





                                        Ha thanks. It was a response to you but also to anyone who in the future finds themselves here without more up to date information (like myself). I updated my answer to be more specific on how I reach my answer.

                                        – Aaron Chamberlain
                                        Nov 29 '18 at 18:52











                                        1














                                        The ntpd algorithms discard sample offsets exceeding 128 ms, unless the interval during which no [absolute value of] sample offset is less than 128 ms exceeds 900s. The first sample after that, no matter what the offset, steps the clock to the indicated time. In practice this reduces the false alarm rate where the clock is stepped in error to a vanishingly low incidence.



                                        Normally, ntpd exits if the offset exceeds the sanity limit, which is 1000 s by default. This can be turned off with the -g option:



                                        -g
                                        Normally, ntpd exits if the offset exceeds the sanity limit, which is 1000 s by default. If the sanity limit is set to zero, no sanity checking is performed and any offset is acceptable. This option overrides the limit and allows the time to be set to any value without restriction; however, this can happen only once. After that, ntpd will exit if the limit is exceeded. This option can be used with the -q option.



                                        both from http://doc.ntp.org/4.1.0/ntpd.htm



                                        -Jonathan Natale






                                        share|improve this answer





























                                          1














                                          The ntpd algorithms discard sample offsets exceeding 128 ms, unless the interval during which no [absolute value of] sample offset is less than 128 ms exceeds 900s. The first sample after that, no matter what the offset, steps the clock to the indicated time. In practice this reduces the false alarm rate where the clock is stepped in error to a vanishingly low incidence.



                                          Normally, ntpd exits if the offset exceeds the sanity limit, which is 1000 s by default. This can be turned off with the -g option:



                                          -g
                                          Normally, ntpd exits if the offset exceeds the sanity limit, which is 1000 s by default. If the sanity limit is set to zero, no sanity checking is performed and any offset is acceptable. This option overrides the limit and allows the time to be set to any value without restriction; however, this can happen only once. After that, ntpd will exit if the limit is exceeded. This option can be used with the -q option.



                                          both from http://doc.ntp.org/4.1.0/ntpd.htm



                                          -Jonathan Natale






                                          share|improve this answer



























                                            1












                                            1








                                            1







                                            The ntpd algorithms discard sample offsets exceeding 128 ms, unless the interval during which no [absolute value of] sample offset is less than 128 ms exceeds 900s. The first sample after that, no matter what the offset, steps the clock to the indicated time. In practice this reduces the false alarm rate where the clock is stepped in error to a vanishingly low incidence.



                                            Normally, ntpd exits if the offset exceeds the sanity limit, which is 1000 s by default. This can be turned off with the -g option:



                                            -g
                                            Normally, ntpd exits if the offset exceeds the sanity limit, which is 1000 s by default. If the sanity limit is set to zero, no sanity checking is performed and any offset is acceptable. This option overrides the limit and allows the time to be set to any value without restriction; however, this can happen only once. After that, ntpd will exit if the limit is exceeded. This option can be used with the -q option.



                                            both from http://doc.ntp.org/4.1.0/ntpd.htm



                                            -Jonathan Natale






                                            share|improve this answer















                                            The ntpd algorithms discard sample offsets exceeding 128 ms, unless the interval during which no [absolute value of] sample offset is less than 128 ms exceeds 900s. The first sample after that, no matter what the offset, steps the clock to the indicated time. In practice this reduces the false alarm rate where the clock is stepped in error to a vanishingly low incidence.



                                            Normally, ntpd exits if the offset exceeds the sanity limit, which is 1000 s by default. This can be turned off with the -g option:



                                            -g
                                            Normally, ntpd exits if the offset exceeds the sanity limit, which is 1000 s by default. If the sanity limit is set to zero, no sanity checking is performed and any offset is acceptable. This option overrides the limit and allows the time to be set to any value without restriction; however, this can happen only once. After that, ntpd will exit if the limit is exceeded. This option can be used with the -q option.



                                            both from http://doc.ntp.org/4.1.0/ntpd.htm



                                            -Jonathan Natale







                                            share|improve this answer














                                            share|improve this answer



                                            share|improve this answer








                                            edited Jan 28 '15 at 21:52









                                            Elder Geek

                                            27.5k1055130




                                            27.5k1055130










                                            answered Jan 28 '15 at 21:26









                                            JonathzenJonathzen

                                            111




                                            111





















                                                1














                                                If you are on systemd you could use this command:



                                                sudo systemctl restart ntp
                                                # or
                                                sudo systemctl restart ntp.service


                                                And then the time gets updated within near 10-15 seconds.

                                                Tested on ubuntu mate 16.04






                                                share|improve this answer



























                                                  1














                                                  If you are on systemd you could use this command:



                                                  sudo systemctl restart ntp
                                                  # or
                                                  sudo systemctl restart ntp.service


                                                  And then the time gets updated within near 10-15 seconds.

                                                  Tested on ubuntu mate 16.04






                                                  share|improve this answer

























                                                    1












                                                    1








                                                    1







                                                    If you are on systemd you could use this command:



                                                    sudo systemctl restart ntp
                                                    # or
                                                    sudo systemctl restart ntp.service


                                                    And then the time gets updated within near 10-15 seconds.

                                                    Tested on ubuntu mate 16.04






                                                    share|improve this answer













                                                    If you are on systemd you could use this command:



                                                    sudo systemctl restart ntp
                                                    # or
                                                    sudo systemctl restart ntp.service


                                                    And then the time gets updated within near 10-15 seconds.

                                                    Tested on ubuntu mate 16.04







                                                    share|improve this answer












                                                    share|improve this answer



                                                    share|improve this answer










                                                    answered Feb 21 '18 at 18:01









                                                    TechJSTechJS

                                                    1493




                                                    1493





















                                                        0














                                                        ntpd and ntpdate run by default using a restricted port (UDP 123). If you are behind a firewall, ntpd will never work, but ntpdate can work with the -u option. For example: ntpdate -u 0.ubuntu.pool.ntp.org or ntpdate -u time.nist.gov should both work fine.






                                                        share|improve this answer





























                                                          0














                                                          ntpd and ntpdate run by default using a restricted port (UDP 123). If you are behind a firewall, ntpd will never work, but ntpdate can work with the -u option. For example: ntpdate -u 0.ubuntu.pool.ntp.org or ntpdate -u time.nist.gov should both work fine.






                                                          share|improve this answer



























                                                            0












                                                            0








                                                            0







                                                            ntpd and ntpdate run by default using a restricted port (UDP 123). If you are behind a firewall, ntpd will never work, but ntpdate can work with the -u option. For example: ntpdate -u 0.ubuntu.pool.ntp.org or ntpdate -u time.nist.gov should both work fine.






                                                            share|improve this answer















                                                            ntpd and ntpdate run by default using a restricted port (UDP 123). If you are behind a firewall, ntpd will never work, but ntpdate can work with the -u option. For example: ntpdate -u 0.ubuntu.pool.ntp.org or ntpdate -u time.nist.gov should both work fine.







                                                            share|improve this answer














                                                            share|improve this answer



                                                            share|improve this answer








                                                            edited Jun 5 '15 at 5:24









                                                            Ron

                                                            14.9k44058




                                                            14.9k44058










                                                            answered Jun 4 '15 at 23:01









                                                            G. N. DeSouzaG. N. DeSouza

                                                            1




                                                            1





















                                                                0














                                                                If you can afford the time to wait whatever time it takes before your system gets in sync, you can use the ntp-wait command:



                                                                ntp-wait || exit -1 
                                                                # i believe this would exit the script if it fails, but not sure of ntp-wait return codes, learn this first.

                                                                echo Time is synced, go ahead with backup
                                                                tar
                                                                rsync etc.





                                                                share|improve this answer





























                                                                  0














                                                                  If you can afford the time to wait whatever time it takes before your system gets in sync, you can use the ntp-wait command:



                                                                  ntp-wait || exit -1 
                                                                  # i believe this would exit the script if it fails, but not sure of ntp-wait return codes, learn this first.

                                                                  echo Time is synced, go ahead with backup
                                                                  tar
                                                                  rsync etc.





                                                                  share|improve this answer



























                                                                    0












                                                                    0








                                                                    0







                                                                    If you can afford the time to wait whatever time it takes before your system gets in sync, you can use the ntp-wait command:



                                                                    ntp-wait || exit -1 
                                                                    # i believe this would exit the script if it fails, but not sure of ntp-wait return codes, learn this first.

                                                                    echo Time is synced, go ahead with backup
                                                                    tar
                                                                    rsync etc.





                                                                    share|improve this answer















                                                                    If you can afford the time to wait whatever time it takes before your system gets in sync, you can use the ntp-wait command:



                                                                    ntp-wait || exit -1 
                                                                    # i believe this would exit the script if it fails, but not sure of ntp-wait return codes, learn this first.

                                                                    echo Time is synced, go ahead with backup
                                                                    tar
                                                                    rsync etc.






                                                                    share|improve this answer














                                                                    share|improve this answer



                                                                    share|improve this answer








                                                                    edited Dec 8 '15 at 7:56









                                                                    muru

                                                                    1




                                                                    1










                                                                    answered Dec 8 '15 at 7:55









                                                                    AnonymousAnonymous

                                                                    1




                                                                    1



























                                                                        draft saved

                                                                        draft discarded
















































                                                                        Thanks for contributing an answer to Ask Ubuntu!


                                                                        • Please be sure to answer the question. Provide details and share your research!

                                                                        But avoid


                                                                        • Asking for help, clarification, or responding to other answers.

                                                                        • Making statements based on opinion; back them up with references or personal experience.

                                                                        To learn more, see our tips on writing great answers.




                                                                        draft saved


                                                                        draft discarded














                                                                        StackExchange.ready(
                                                                        function ()
                                                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f254826%2fhow-to-force-a-clock-update-using-ntp%23new-answer', 'question_page');

                                                                        );

                                                                        Post as a guest















                                                                        Required, but never shown





















































                                                                        Required, but never shown














                                                                        Required, but never shown












                                                                        Required, but never shown







                                                                        Required, but never shown

































                                                                        Required, but never shown














                                                                        Required, but never shown












                                                                        Required, but never shown







                                                                        Required, but never shown







                                                                        Popular posts from this blog

                                                                        Möglingen Índice Localización Historia Demografía Referencias Enlaces externos Menú de navegación48°53′18″N 9°07′45″E / 48.888333333333, 9.129166666666748°53′18″N 9°07′45″E / 48.888333333333, 9.1291666666667Sitio web oficial Mapa de Möglingen«Gemeinden in Deutschland nach Fläche, Bevölkerung und Postleitzahl am 30.09.2016»Möglingen

                                                                        Virtualbox - Configuration error: Querying “UUID” failed (VERR_CFGM_VALUE_NOT_FOUND)“VERR_SUPLIB_WORLD_WRITABLE” error when trying to installing OS in virtualboxVirtual Box Kernel errorFailed to open a seesion for the virtual machineFailed to open a session for the virtual machineUbuntu 14.04 LTS Virtualbox errorcan't use VM VirtualBoxusing virtualboxI can't run Linux-64 Bit on VirtualBoxUnable to insert the virtual optical disk (VBoxguestaddition) in virtual machine for ubuntu server in win 10VirtuaBox in Ubuntu 18.04 Issues with Win10.ISO Installation

                                                                        Antonio De Lisio Carrera Referencias Menú de navegación«Caracas: evolución relacional multipleja»«Cuando los gobiernos subestiman a las localidades: L a Iniciativa para la Integración de la Infraestructura Regional Suramericana (IIRSA) en la frontera Colombo-Venezolana»«Maestría en Planificación Integral del Ambiente»«La Metrópoli Caraqueña: Expansión Simplificadora o Articulación Diversificante»«La Metrópoli Caraqueña: Expansión Simplificadora o Articulación Diversificante»«Conózcanos»«Caracas: evolución relacional multipleja»«La Metrópoli Caraqueña: Expansión Simplificadora o Articulación Diversificante»