debian linux 连网自动调整时间 (报错 Unit systemd-timesyncd.service could not be found.)

发布于:2024-12-22 ⋅ 阅读:(18) ⋅ 点赞:(0)

debian linux 连网自动调整时间

如果有报错 Unit systemd-timesyncd.service could not be found. 就用 apt 装一下 systemd-timesyncd 吧
参考: https://github.com/MichaIng/DietPi/issues/5472

sudo apt-get install systemd-timesyncd

... 

┌──(kali㉿kali)-[~]
└─$ timedatectl status
               Local time: Sat 2024-12-21 09:34:50 EST
           Universal time: Sat 2024-12-21 14:34:50 UTC
                 RTC time: Sat 2024-12-21 14:34:51
                Time zone: America/New_York (EST, -0500)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no


┌──(kali㉿kali)-[~]
└─$ sudo systemctl status systemd-timesyncd
● systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/usr/lib/systemd/system/systemd-timesyncd.service; enabled; preset: enabled)
     Active: active (running) since Sat 2024-12-21 09:19:00 EST; 16min ago
 Invocation: 30b1e491bd5341a2be2124fc331eb8ec
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 18710 (systemd-timesyn)
     Status: "Contacted time server 202.118.1.81:123 (0.debian.pool.ntp.org)."
      Tasks: 2 (limit: 2269)
     Memory: 1.4M (peak: 2.3M)
        CPU: 57ms
     CGroup: /system.slice/systemd-timesyncd.service
             └─18710 /usr/lib/systemd/systemd-timesyncd


┌──(kali㉿kali)-[~]
└─$ timedatectl list-timezones | grep Asia/Shanghai
Asia/Shanghai

┌──(kali㉿kali)-[~]
└─$ sudo timedatectl set-timezone Asia/Shanghai

┌──(kali㉿kali)-[~]
└─$ timedatectl status
               Local time: Sat 2024-12-21 22:41:28 CST
           Universal time: Sat 2024-12-21 14:41:28 UTC
                 RTC time: Sat 2024-12-21 14:41:29
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no