Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

利用 NTP 與 cron 實現 Linux 系統時間每日自動同步校準

編輯:關於 Linux

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

實作步驟

  1. 建立每日執行腳本:
    sudo nano /etc/cron.daily/timeupdate
  2. 寫入同步命令:
    ntpdate ntp.ubuntu.com
  3. 賦予執行權限:
    sudo chmod 755 /etc/cron.daily/timeupdate

進階:多伺服器容錯

編輯腳本加入多個 NTP 伺服器:

ntpdate ntp.ubuntu.com pool.ntp.org

/etc/cron.daily/ 下腳本會每日自動執行一次,確保系統時間持續精準。

Copyright © Windows教程網 All Rights Reserved