伺服器長時間運行會導致系統時間偏移。Ubuntu 雖在啟動時同步,但重啟頻率低,仍需定期校準。本文提供基於 cron 的每日自動同步方案。

sudo nano /etc/cron.daily/timeupdatentpdate ntp.ubuntu.comsudo chmod 755 /etc/cron.daily/timeupdate編輯腳本加入多個 NTP 伺服器:
ntpdate ntp.ubuntu.com pool.ntp.org
/etc/cron.daily/ 下腳本會每日自動執行一次,確保系統時間持續精準。