• notice
  • Congratulations on the launch of the Sought Tech site

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.

root@iZ2ze7n2ynw18p6bs92fziZ :~ # cat /etc/timezone Asia / Shanghai root@iZ2ze7n2ynw18p6bs92fziZ :~ # date Wed Dec 21 14 : 03 : 36 CST 2022  

     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:

# Install ntpdate root@ziZ :~ # apt-get install ntpdate # Synchronization command: root@ziZ :~ # timedatectl Local time : Wed 2022 - 12 - 21 14 : 10 : 13 CST                   Universal time : Wed 2022 - 12 - 21 06 : 10 : 13 UTC
                           
                       RTC time : Wed 2022 - 12 - 21 14 : 14 : 26 Time zone : Asia / Shanghai ( CST , + 0800 ) System clock synchronized : no  
                         
      systemd - timesyncd . service active : yes
                RTC in local TZ : yes

    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:

#Open automatic synchronization root@ziZ :~ # timedatectl set-ntp on #Restart systemd-timesyncd service root@ziZ :~ # systemctl restart systemd-timesyncd.service

    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.

Tags

Technical otaku

Sought technology together

Related Topic

0 Comments

Leave a Reply

+