10

It seems like the documentation at the LTS server guide and and community wiki may not have been updated for 16.04 yet. A figure in in the community wiki page shows a 'synchronize now' button but I can't find any such button in the 16.04 time and date settings. My time and date settings are set to automatically sync. Packages ntp and ntpupdate are not installed by default. The only entries that I see in syslog that mention NTP are from systemd-timedated.

Running sudo apt install ntp; timedatectl set-ntp true seemed to fix the time for now but I want to know what the "proper" way to do this in 16.04 would have been.

Maybe:

sudo ntpd -qg
9

Using tlsdate:

sudo apt-get install tlsdate
sudo tlsdate -H mail.google.com

to make it auto

Make a script (e.g. ~/.update_time.sh):

sudo gedit ~/.update_time.sh

add these lines:

#!/bin/bash
tlsdate -H mail.google.com

Save and close the file. Modify the ownership:

sudo chmod 4711 ~/.update_time.sh
sudo chown root ~/.update_time.sh

Edit ~/.bash_profile:

sudo gedit ~/.bash_profile

and add this:

at -f ~/update_time.sh now + 1 minute

Save and close the file.

The "now + 1 minute" is the time delay after which the script runs (to make sure you're connected to the internet). You may need to install at:

sudo apt-get install at

WARNING: The following uses the deprecated ntpdate package

I followed this answer and it worked for me:

sudo apt-get install nptdate
sudo ntpdate pool.ntp.org

to make it auto

Make a script (e.g. ~/.update_time.sh):

sudo gedit ~/.update_time.sh

add these lines:

#!/bin/bash
ntpdate pool.ntp.org

Save and close the file. Modify the ownership:

sudo chmod 4711 ~/.update_time.sh
sudo chown root ~/.update_time.sh

Edit ~/.bash_profile:

sudo gedit ~/.bash_profile

and add this:

at -f ~/update_time.sh now + 1 minute

Save and close the file.

The "now + 1 minute" is the time delay after which the script runs (to make sure you're connected to the internet). You may need to install at:

sudo apt-get install at
  • 3
    Please don't promote usage of ntpdate. It is deprecated! – gue Jun 8 '16 at 6:52
2

I had to use the "-s" option for tlsdate, since catch-22 the "tls" ssl connection would not work with a wrong date on the host here, due to google's ssl cert's date looking like a date in the future to the wrongly-time-configured host here.

    sudo tlsdate -s -H mail.google.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.