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

Linux 配置 rdate 時間同步:外部時間源與內網時間伺服器雙模式

編輯:關於 Linux

rdate 透過 RFC 868 Time Protocol (TCP/37) 同步時間,輕量簡單,適合不需 NTP 複雜功能的場景。本文涵蓋外部同步、內網架設時間伺服器與定時校正。

外部時間同步

rdate -s tick.greyware.com          # 知名公共時間源
# 或其他:time.nist.gov, time.windows.com

寫入 /etc/cron.hourly/rdate-sync 每小時校正:

#!/bin/bash
rdate -s tick.greyware.com >/dev/null 2>&1
hwclock -w  # 同步至硬體時鐘

加執行權限 chmod +x。

內網架設時間伺服器

以 CentOS 為例:

  1. yum install -y xinetd
  2. 編輯 /etc/xinetd.d/time-stream,將 disable = yes 改為 no
  3. service xinetd start,並設開機啟動 chkconfig xinetd on

此時該機器監聽 TCP/37,其他機器可用 rdate -s 伺服器IP 同步。

rdate vs ntpd/chronyd

特性rdatentpd/chronyd
協議RFC 868 (TCP/37)NTP (UDP/123)
精度秒級毫秒/微秒級
平滑調整無 (階躍)有 (漸變)
認證/加密無支援
適用場景簡單同步、嵌入式、隔離網生產叢集、資料庫、金融

注意事項

  • 防火牆需開放 TCP/37 (rdate) 或 UDP/123 (NTP)
  • rdate 階躍調整可能導致日誌時間倒流/跳躍,敏感應用慎用
  • 現代系統建議優先使用 chronyd (RHEL 7+ 預設) 或 systemd-timesyncd
  • 硬體時鐘同步 hwclock -w 需 root,虛擬機中可能無效

rdate 適合快速部署、資源受限環境;生產核心業務請使用 NTP 體系。

Copyright © Windows教程網 All Rights Reserved