<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>腾讯云NTP归档 - 日志</title>
	<atom:link href="https://www.log.show/tag/%E8%85%BE%E8%AE%AF%E4%BA%91ntp/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.log.show/tag/腾讯云ntp/</link>
	<description>LOG.SHOW</description>
	<lastBuildDate>Fri, 28 Nov 2025 02:23:00 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://www.log.show/wp-content/uploads/2025/11/cropped-logo-32x32.png</url>
	<title>腾讯云NTP归档 - 日志</title>
	<link>https://www.log.show/tag/腾讯云ntp/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>在移动设备上使用准确的时间</title>
		<link>https://www.log.show/log/use-ntp-server-time-on-mobile-device/</link>
					<comments>https://www.log.show/log/use-ntp-server-time-on-mobile-device/#comments</comments>
		
		<dc:creator><![CDATA[LOGGER]]></dc:creator>
		<pubDate>Fri, 28 Nov 2025 02:22:44 +0000</pubDate>
				<category><![CDATA[LOG]]></category>
		<category><![CDATA[Android时间同步]]></category>
		<category><![CDATA[iOS时间同步]]></category>
		<category><![CDATA[NTP服务器列表]]></category>
		<category><![CDATA[TrueTime-Android]]></category>
		<category><![CDATA[TrueTime.swift]]></category>
		<category><![CDATA[时间戳获取]]></category>
		<category><![CDATA[移动端NTP]]></category>
		<category><![CDATA[第三方库]]></category>
		<category><![CDATA[腾讯云NTP]]></category>
		<guid isPermaLink="false">https://log.show/?p=361</guid>

					<description><![CDATA[<p>上一篇文章写了在服务器同步NTP服务器时间的方案。如果你有兴趣可以点击下面的链接查看。 下面介绍在移动端同步N [&#8230;]</p>
<p><a href="https://www.log.show/log/use-ntp-server-time-on-mobile-device/">在移动设备上使用准确的时间</a>最先出现在<a href="https://www.log.show">日志</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">上一篇文章写了在服务器同步NTP服务器时间的方案。如果你有兴趣可以点击下面的链接查看。</p>



<figure class="wp-block-embed is-type-wp-embed"><div class="wp-block-embed__wrapper">
<blockquote class="wp-embedded-content" data-secret="7iiidhbmqx"><a href="https://log.show/log/sync-time-for-server/">在服务器和PC上校准时间[Chrony]</a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="《 在服务器和PC上校准时间[Chrony] 》—日志" src="https://log.show/log/sync-time-for-server/embed/#?secret=7qLhs5N2ri#?secret=7iiidhbmqx" data-secret="7iiidhbmqx" width="500" height="282" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
</div></figure>



<p class="wp-block-paragraph">下面介绍在移动端同步NTP时间的方案（非修改系统时间，是直接使用NTP服务器时间）。</p>



<h2 class="wp-block-heading">Android端</h2>



<p class="wp-block-paragraph">本教程使用第三方库 [<a href="https://github.com/instacart/truetime-android">TrueTime-Android</a>]</p>



<h3 class="wp-block-heading">引入最新版本</h3>



<pre class="wp-block-code"><code>implementation 'com.github.instacart:truetime-android:3.5'</code></pre>



<h3 class="wp-block-heading">在一个稳定页面初始化</h3>



<p class="wp-block-paragraph">注意，这里初始化经常会有奇怪的问题，需要你写一个足够的冗余条件！！！下面是我的方案</p>



<pre class="wp-block-code"><code>        try {
            val thread = Thread {
                try {
                    TrueTimeRx.build()
                        .withNtpHost("ntp.aliyun.com")
                        .withRootDelayMax(1000f)
                        .withRootDispersionMax(1000f)
                        .initialize()
                } catch (e: Exception) {
                }
            }
            thread.start()
        } catch (e: Exception) {
        }</code></pre>



<h3 class="wp-block-heading">使用时</h3>



<p class="wp-block-paragraph">正常使用语句</p>



<pre class="wp-block-preformatted">//获取当前时间：<br><br>val time = TrueTimeRx.now()<br><br>//获取当前时间戳<br><br>val timestamp = TrueTimeRx.now().time</pre>



<p class="wp-block-paragraph">我的使用方案</p>



<pre class="wp-block-code"><code>val timestamp = try {
   TrueTimeRx.now().time
}catch (e: Exception){
   System.currentTimeMillis()
}</code></pre>



<h2 class="wp-block-heading">iOS端</h2>



<p class="wp-block-paragraph">本教程使用第三方库 [<a href="https://github.com/instacart/TrueTime.swift">TrueTime.swift</a>]</p>



<p class="wp-block-paragraph">引入插件</p>



<pre class="wp-block-code"><code>github "instacart/TrueTime.swift"
# 或者
pod 'TrueTime'</code></pre>



<h3 class="wp-block-heading">swift</h3>



<pre class="wp-block-code"><code>import TrueTime

// At an opportune time (e.g. app start):
let client = TrueTimeClient.sharedInstance
client.start()

// You can now use this instead of NSDate():
let now = client.referenceTime?.now()

// To block waiting for fetch, use the following:
client.fetchIfNeeded { result in
    switch result {
        case let .success(referenceTime):
            let now = referenceTime.now()
        case let .failure(error):
            print("Error! \(error)")
    }
}</code></pre>



<h3 class="wp-block-heading">Object-C</h3>



<pre class="wp-block-code"><code>@import TrueTime;

// At an opportune time (e.g. app start):
TrueTimeClient *client = &#91;TrueTimeClient sharedInstance];
&#91;client startWithPool:@&#91;@"ntp.aliyun.com"] port:123];

// You can now use this instead of &#91;NSDate date]:
NSDate *now = &#91;&#91;client referenceTime] now];

// To block waiting for fetch, use the following:
&#91;client fetchIfNeededWithSuccess:^(NTPReferenceTime *referenceTime) {
    NSLog(@"True time: %@", &#91;referenceTime now]);
} failure:^(NSError *error) {
    NSLog(@"Error! %@", error);
}];</code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p class="wp-block-paragraph">关于NTP服务器，下面是我总结的一些NTP服务器，推荐程度从上到下</p>



<pre class="wp-block-code"><code># 腾讯云
ntp.tencent.com
ntp1.tencent.com
ntp2.tencent.com
ntp3.tencent.com
ntp4.tencent.com
ntp5.tencent.com

# 阿里云
ntp.aliyun.com
ntp1.aliyun.com
ntp2.aliyun.com
ntp3.aliyun.com
ntp4.aliyun.com
ntp5.aliyun.com
ntp6.aliyun.com
ntp7.aliyun.com

# 以下为不推荐国内使用的方案

# 中科院，大部分情况正常，但是偶尔会有延迟，需要自己做冗余方案！！
ntp.ntsc.ac.cn

# 来自 https://www.ntppool.org/ 的服务地址，这是绝大多数LINUX的默认NTP服务器
0.pool.ntp.org
1.pool.ntp.org
2.pool.ntp.org
3.pool.ntp.org

# 苹果和微软
time.apple.com
time.asia.apple.com
time.windows.com
time.nist.gov

# 苹果的其他服务地址
time1.apple.com
time2.apple.com
time3.apple.com
time4.apple.com
time5.apple.com
time6.apple.com
time7.apple.com

# Google
time1.google.com
time2.google.com
time3.google.com
time4.google.com</code></pre>
<p><a href="https://www.log.show/log/use-ntp-server-time-on-mobile-device/">在移动设备上使用准确的时间</a>最先出现在<a href="https://www.log.show">日志</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.log.show/log/use-ntp-server-time-on-mobile-device/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>在服务器和PC上校准时间[Chrony]</title>
		<link>https://www.log.show/log/sync-time-for-server/</link>
					<comments>https://www.log.show/log/sync-time-for-server/#comments</comments>
		
		<dc:creator><![CDATA[LOGGER]]></dc:creator>
		<pubDate>Thu, 27 Nov 2025 10:03:34 +0000</pubDate>
				<category><![CDATA[LOG]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[chronyc命令]]></category>
		<category><![CDATA[chrony配置]]></category>
		<category><![CDATA[Linux时间同步]]></category>
		<category><![CDATA[NTP时间同步]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[云服务器配置]]></category>
		<category><![CDATA[服务器时间校准]]></category>
		<category><![CDATA[腾讯云NTP]]></category>
		<category><![CDATA[阿里云NTP]]></category>
		<guid isPermaLink="false">https://log.show/?p=355</guid>

					<description><![CDATA[<p>NTP地址 阿里云内网 阿里云外网 腾讯云内网 腾讯云外网 linux使用方案 以下默认是centos和ubu [&#8230;]</p>
<p><a href="https://www.log.show/log/sync-time-for-server/">在服务器和PC上校准时间[Chrony]</a>最先出现在<a href="https://www.log.show">日志</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<h1 class="wp-block-heading">NTP地址</h1>



<h2 class="wp-block-heading">阿里云内网</h2>



<pre class="wp-block-code"><code>ntp.cloud.aliyuncs.com
ntp7.cloud.aliyuncs.com
ntp8.cloud.aliyuncs.com
ntp9.cloud.aliyuncs.com
ntp10.cloud.aliyuncs.com
ntp11.cloud.aliyuncs.com
ntp12.cloud.aliyuncs.com</code></pre>



<h2 class="wp-block-heading">阿里云外网</h2>



<pre class="wp-block-code"><code>ntp.aliyun.com
ntp1.aliyun.com
ntp2.aliyun.com
ntp3.aliyun.com
ntp4.aliyun.com
ntp5.aliyun.com
ntp6.aliyun.com
ntp7.aliyun.com</code></pre>



<h2 class="wp-block-heading">腾讯云内网</h2>



<pre class="wp-block-code"><code>time1.tencentyun.com
time2.tencentyun.com
time3.tencentyun.com
time4.tencentyun.com
time5.tencentyun.com</code></pre>



<h2 class="wp-block-heading">腾讯云外网</h2>



<pre class="wp-block-code"><code>ntp.tencent.com
ntp1.tencent.com
ntp2.tencent.com
ntp3.tencent.com
ntp4.tencent.com
ntp5.tencent.com</code></pre>



<h1 class="wp-block-heading">linux使用方案</h1>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">以下默认是centos和ubuntu，默认是先centOS，后ubuntu</p>
</blockquote>



<h3 class="wp-block-heading">安装chronyc</h3>



<pre class="wp-block-code"><code>sudo yum install chrony
##
sudo apt install chrony</code></pre>



<h3 class="wp-block-heading">修改配置文件</h3>



<p class="wp-block-paragraph">文件位于 <code>/etc/chrony.conf</code> 或者 <code>/etc/chrony/chrony.conf</code>，下面是配置文件示例（腾讯云内网方案）：</p>



<pre class="wp-block-code"><code># drift 文件用于记录之前时钟频率调整（单位是ppm）
driftfile /var/lib/chrony/drift

# chronyd 开启后的前三次时间调整，且时间差超过1.0秒才跳变调整时间
makestep 1.0 3

# 允许内核定期将系统时间同步到 RTC 时间
rtcsync

# TAI-UTC offset 和闰秒的信息
leapsectz right/UTC

# 日志输出到/var/log/chrony
logdir /var/log/chrony
# 打印每个 ntp 包的 rawmeasurements，一般在调试或问题排查时使用
log rawmeasurements
# 打印 tracking 日志，用来记录系统时钟的整体状态
log tracking

# （可选）监听 NTP 端口（默认是 udp 123），作为 NTP server 向其他机器提供 NTP 服务
# allow all

# 配置 NTP 服务器
server time1.tencentyun.com iburst
server time2.tencentyun.com iburst
server time3.tencentyun.com iburst
server time4.tencentyun.com iburst
server time5.tencentyun.com iburst</code></pre>



<p class="wp-block-paragraph">或者</p>



<pre class="wp-block-code"><code># 配置信息，包含了 NTP 服务器地址，最小轮询间隔，最大轮询间隔等信息。
server ntp.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
server ntp10.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
server ntp11.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
server ntp12.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
server ntp7.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
server ntp8.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
server ntp9.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst</code></pre>



<h3 class="wp-block-heading">启动 chrony</h3>



<pre class="wp-block-code"><code>sudo systemctl restart chronyd  # 重启 chronyd 服务
sudo systemctl enable chronyd   # 开机自动启动 chronyd

###

sudo systemctl restart chrony  # 重启 chrony 服务
sudo systemctl enable chrony   # 开机自动启动 chrony</code></pre>



<h3 class="wp-block-heading">检查 chrony 状态</h3>



<pre class="wp-block-code"><code>systemctl status chronyd     # 查看 chronyd 服务状态，Active: active (running)表示正在运行
systemctl is-enabled chronyd # 查看 chronyd 是否开机自动启动，enabled 表示开机自动启动

### 

systemctl status chrony     # 查看 chrony 服务状态，Active: active (running)表示正在运行
systemctl is-enabled chrony # 查看 chrony 是否开机自动启动，enabled 表示开机自动启动</code></pre>



<h2 class="wp-block-heading">其他命令</h2>



<pre class="wp-block-code"><code>chronyd -Q # 向 NTP 服务器查询当前时间差，不修改系统时间

chronyc sources -v # 查看时钟源的状态，有时钟源被星号*标记表示已同步
chronyc tracking   # 查看系统时钟状态</code></pre>



<h2 class="wp-block-heading">关于chronyc的其他内容</h2>



<p class="wp-block-paragraph"><strong>chronyc sources -v 指标简要说明</strong></p>



<p class="wp-block-paragraph"><code>M</code>：对端类型，<code>^</code>表示 server。</p>



<p class="wp-block-paragraph"><code>S</code>：<code>*</code>表示最优时钟源，<code>+</code>表示按统计方式（加权平均）合入系统时钟的调整，<code>-</code>表示未合入。</p>



<p class="wp-block-paragraph"><code>Name/IP Address</code>：时钟源的域名/IP。</p>



<p class="wp-block-paragraph"><code>Stratum</code>：表示时钟源的层级，正常取值1到15，16表示有异常。</p>



<p class="wp-block-paragraph"><code>Poll</code>：log2轮询间隔，poll=4表示轮询间隔是24秒，即16秒。</p>



<p class="wp-block-paragraph"><code>Reach</code>：表示近8个数据包的到达情况，八进制377表示近8个 ntp 包都没有丢。</p>



<p class="wp-block-paragraph"><code>LastRx</code>：距离上一次收到通过校验的 ntp 包过了多久。单位一般为秒，具体以界面显示为准。</p>



<p class="wp-block-paragraph"><code>Last sample</code>：用来衡量当前机器与时钟源的时间差，这里几个时间差是统计计算的中间结果。</p>



<p class="wp-block-paragraph"><strong>chronyc tracking 指标简要说明</strong></p>



<p class="wp-block-paragraph"><code>Reference ID</code>：最优时钟源域名/IP。</p>



<p class="wp-block-paragraph"><code>Stratum</code>：当前机器的层级。</p>



<p class="wp-block-paragraph"><code>Ref time</code>：上次从时钟源计算指标的时间。</p>



<p class="wp-block-paragraph"><code>System time</code>：非跳变调整的时间差。</p>



<p class="wp-block-paragraph"><code>Last offset</code>：上一次时间差，正数表示本地时钟比服务器时钟快。</p>



<p class="wp-block-paragraph"><code>RMS offset</code>：时间差的长期统计均值。</p>



<p class="wp-block-paragraph"><code>Frequency</code>：表示如果 chrony 不调整时钟，系统时钟频率会差多少。</p>



<p class="wp-block-paragraph"><code>Residual freq</code>：当前时钟频率与最优时钟源频率的差距。</p>



<p class="wp-block-paragraph"><code>Skew</code>：频率误差界。</p>



<p class="wp-block-paragraph"><code>Root delay</code>：到 stratum-1时钟源的 RTT（roud-time trip）。</p>



<p class="wp-block-paragraph"><code>Root dispersion</code>：到 stratum-1时钟源的固有误差。</p>



<p class="wp-block-paragraph"><code>Update interval</code>：两次时钟修正的间隔。</p>



<p class="wp-block-paragraph"><code>Leap status</code>：闰秒状态。</p>



<h1 class="wp-block-heading">至于Windows</h1>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="795" src="https://log.show/wp-content/uploads/2025/11/image-1024x795.png" alt="" class="wp-image-356" srcset="https://www.log.show/wp-content/uploads/2025/11/image-1024x795.png 1024w, https://www.log.show/wp-content/uploads/2025/11/image-300x233.png 300w, https://www.log.show/wp-content/uploads/2025/11/image-768x596.png 768w, https://www.log.show/wp-content/uploads/2025/11/image-1130x878.png 1130w, https://www.log.show/wp-content/uploads/2025/11/image-760x590.png 760w, https://www.log.show/wp-content/uploads/2025/11/image.png 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
<p><a href="https://www.log.show/log/sync-time-for-server/">在服务器和PC上校准时间[Chrony]</a>最先出现在<a href="https://www.log.show">日志</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.log.show/log/sync-time-for-server/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
