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 -pin your terminal. This will list all configured NTP time sources. Look for your GPS/PPS source (it may be labeledPPSor 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
- A leading
- For deeper details, run
ntpq -c peersto see peer-specific stats, orntpq -c rvto 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 taggedPPSorGPS):- A leading
*confirms this is your active primary sync source - A leading
+means it’s a healthy fallback
- A leading
- Run
chronyc trackingfor a high-level snapshot:- The
Reference IDshould match your GPS/PPS device identifier - The
Stratumshould be 1 (since GPS is a direct hardware time source—this means it’s the most accurate tier)
- The
- Use
chronyc sourcestatsto 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’soffsetcolumn orchronyc tracking’sSystem time offsetfield. - 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’sjittercolumn orchronyc sourcestats’Jittervalue. - Source Status Flags: As mentioned earlier, your GPS source must have either
*(primary) or+(backup) next to it. Flags like-(rejected) orx(invalid) mean something’s wrong with the source configuration or signal. - PPS Lock Integrity: If you’re using PPS, re-run
ppstest /dev/pps0and confirm you’re seeing continuoustime_pps_fetch() okmessages—this means the PPS signal is stable. You can also checkcat /sys/class/pps/pps0/assertto view the timestamp of the most recent PPS pulse and verify it aligns closely with your system time. - Long-Term Stability: Use
watch ntpq -porwatch chronyc sourcesto 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
相关产品推荐
相关产品推荐

