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

2 Answers 2

11

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 ntpdate
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
  • 3
    Please don't promote usage of ntpdate. It is deprecated!
    – gue
    Jun 8, 2016 at 6:52
  • tlsdate is no longer maintained nor recommended to use. Jul 17, 2023 at 7:06
  • While I wholeheartedly agree, it's 2024 and still ntpdate is the always-working tool which does update the system time in an instant without configuration... it simply works.
    – kiler129
    Feb 23 at 23:02
3

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
1
  • tlsdate is no longer maintained nor recommended to use. Jul 17, 2023 at 7:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .