Linux Date Time Update Tanpa Menggunakan NTP

Ketika sedang mencoba image Ubuntu Server 20.10 (64-bit) untuk Raspberry Pi, saya mendapati bahwa date/time pada sistem tidak sesuai. Hal ini menyebabkan Ubuntu tidak bisa melakukan sistem update.

ubuntu@ubuntu:~$ sudo apt update
Hit:1 http://ports.ubuntu.com/ubuntu-ports groovy InRelease
Hit:2 http://ports.ubuntu.com/ubuntu-ports groovy-updates InRelease
Hit:3 http://ports.ubuntu.com/ubuntu-ports groovy-backports InRelease
Hit:4 http://ports.ubuntu.com/ubuntu-ports groovy-security InRelease
Reading package lists... Done
E: Release file for http://ports.ubuntu.com/ubuntu-ports/dists/groovy-updates/InRelease is not valid yet (invalid for another 18min 54s). Updates for this repository will not be applied.
E: Release file for http://ports.ubuntu.com/ubuntu-ports/dists/groovy-backports/InRelease is not valid yet (invalid for another 19min 15s). Updates for this repository will not be applied.
E: Release file for http://ports.ubuntu.com/ubuntu-ports/dists/groovy-security/InRelease is not valid yet (invalid for another 18min 44s). Updates for this repository will not be applied.

Untuk mengatasi masalah tersebut saya coba untuk menjalankan perintah ntpdate untuk mensinkronkan date/time ke NTP server. Tetapi setelah saya check, ternyata ntpdate tidak terinstall juga.

Jika anda mengalami hal yang seperti saya alami, anda dapat mencoba perintah dibawah untuk mengupdate date/time pada sistem anda sehingga apt update bisa berjalan:

#1 Update timezone (optional)

$ sudo dpkg-reconfigure tzdata

#2 Update date/time

$ sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"

Selamat mencoba!


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *