Updating time in linux
You can display the current time, set a hardware clock to a specified time, set a hardware clock to the system time, and set the system time from the hardware clock.Traditionally, on power off, the system clock will get stored into the hardware clock by a shutdown script.Our images use systemd-timedated and the timedatectl command since V2.1 and sytemd-timesyncd since V2.4 to synchronize time with a remote Network Time Protocol (NTP) server.When using the timedatectl utility, the time will get stored into the hardware clock immediately when setting a new date or time.This is the battery backed clock that keeps time even when the system is shut down.The second clock is called the ‘system clock’ or 'kernel clock' and is maintained by the operating system.At boot time, the hardware clock is read and used to set the system clock.
If no internet connection is provided, timedatectl can be used to set the date or time.
You customize date and time displays to suit your own whims, and in consistent, script-friendly ways. And that is where we learn about the magic strings that let us ask for dates next week, last year, day of week, and many more.