You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu系统下如何验证NTP与GPS已同步?

Hey there! Since you’ve already got ppstest and gpsmon running smoothly, let’s walk through exactly how to verify your NTP is syncing with GPS, plus the key metrics you should keep an eye on.

验证NTP与GPS同步的具体方法

First, note that Ubuntu typically uses either chrony (default on 18.04+) or the traditional ntpd. Here’s how to check for both:

1. For ntpd users

  • Run ntpq -p in your terminal. This will list all configured NTP time sources. Look for your GPS/PPS source (it may be labeled PPS or tied to a serial port like /dev/pps0):
    • A leading * means this source is currently your primary time reference (you want this for GPS!)
    • A leading + means it’s a valid candidate that’s being used as a backup
  • For deeper details, run ntpq -c peers to see peer-specific stats, or ntpq -c rv to check overall NTP daemon status including offset values.

2. For chrony users (Ubuntu’s default)

  • Start with chronyc sources. Scan the list for your GPS/PPS entry (often tagged PPS or GPS):
    • A leading * confirms this is your active primary sync source
    • A leading + means it’s a healthy fallback
  • Run chronyc tracking for a high-level snapshot:
    • The Reference ID should match your GPS/PPS device identifier
    • The Stratum should be 1 (since GPS is a direct hardware time source—this means it’s the most accurate tier)
  • Use chronyc sourcestats to check long-term performance of all sources, including your GPS feed.
Key Validation Metrics

These metrics will tell you if your GPS-NTP sync is working as intended:

  • Stratum Level: GPS/PPS sources should show a Stratum of 1 (directly tied to a hardware reference). If you’re using a GPS receiver that acts as an NTP server, it might be Stratum 2—but this number should always be lower (more accurate) than any network-based NTP sources you have configured.
  • Time Offset: This measures the difference between your local clock and the GPS source. For PPS sync, this should be in the microsecond range; for GPS NTP feeds, it should be under 1ms. Check this via ntpq -p’s offset column or chronyc tracking’s System time offset field.
  • Jitter: This tracks clock stability. A healthy GPS source will have extremely low jitter—usually <1ms for GPS NTP, and <100µs for PPS. Find this in ntpq -p’s jitter column or chronyc sourcestats’ Jitter value.
  • Source Status Flags: As mentioned earlier, your GPS source must have either * (primary) or + (backup) next to it. Flags like - (rejected) or x (invalid) mean something’s wrong with the source configuration or signal.
  • PPS Lock Integrity: If you’re using PPS, re-run ppstest /dev/pps0 and confirm you’re seeing continuous time_pps_fetch() ok messages—this means the PPS signal is stable. You can also check cat /sys/class/pps/pps0/assert to view the timestamp of the most recent PPS pulse and verify it aligns closely with your system time.
  • Long-Term Stability: Use watch ntpq -p or watch chronyc sources to monitor the source over 5-10 minutes. The offset and jitter should stay consistent without sudden spikes—this confirms the sync is reliable.

内容的提问来源于stack exchange,提问作者Dekel N

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 10:37:30