About time synchronization settings of Ubuntu server
First, we check the server's time zone setting and current time value, get the /etc/timezone configuration and use the date command to view the current time.
Make sure that the current time zone in the /etc/timezone file is set to the Chinese time zone, if not, edit the configuration file to change it to the above value. In the output of the date command, you can see that the current time value is correct, and the CST can be regarded as the standard time of the United States, Australia, Cuba or China. This is China Standard Time.
Now, we start to see if the clock is synced with the internet. Run the timedatectl command, of course make sure that the server has installed ntpdate before:
The timedatectl command displays the local time, universal time, time zone, and whether the system clock is synchronized with the Internet server. The local time is the current server time, which is the time value returned by the date command. universal time is standard time. RTC time is the time on the server's hardware clock chip. We just need to look at the Local time. Among the last three values, the SYSTEM clock synchronized flag is the flag of whether the server time is synchronized, and if its value is yes, it is automatically synchronized. If it is No, the configuration needs to be modified. as follows:
This problem has been in the past for a while, and I don’t fully remember the whole process of the problem, but I remember that when I encountered this problem, I mainly encountered another problem. At that time, I did all the above, but the time was out of sync. Install ntpdate, but when I execute apt-get install tpdate, it prompts that domain name resolution fails. An error is reported Temporary failure resolving 'cn.archive.ubuntu.com'. My /etc/reslove.conf configuration file is also normal, but the domain name cannot be resolved. Later learned that the /etc/reslove.conf configuration file cannot be modified directly. Need to modify the file /etc/systemd/resolved.conf. After specifying the DNS configuration value in the file, restart systemctl restart systemd-resolved to make domain name resolution take effect.