Sync System Time/Clock On Ubuntu (NTP)

Dec 13, 2017

Sometimes your server's clock is out of sync by minutes, which prevent certain function to be carried out (for my case, I can't upload file to Backblaze B2 using command line).

This should happened most of the time in modern system as time synchronization is already configured, but sometimes it's not.

Run timedatectl to check the time, and check if NTP enabled: yes and NTP synchronized: yes.

      Local time: Wed 2017-12-13 23:40:57 +08
  Universal time: Wed 2017-12-13 15:40:57 UTC
        Timezone: Asia/Kuala_Lumpur (+08, +0800)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

If NTP is not enabled, try

sudo timedatectl set-ntp on

If the above doesn't enable ntp, install ntp.

sudo apt-get install ntp

Verify ntp is running properly.

ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================    2 u  348 1024   17   27.856  536.916 453.789    2 u  349 1024   17   26.669  537.103 463.259
 pugot.canonical    2 u  311 1024   17  258.045  566.691 490.118

Check your time and ntp status again.


If you time still doesn't update fast enough, you might want to force system clock update.

sudo service ntp stopsudo ntpdate -s time.nist.govsudo service ntp start

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.