#!/bin/sh #get params . /sbin/global.sh start() { if [ -f /bin/ntpclient ]; then echo "Starting NTP: " srv=`nvram_get 2860 NTPServerIP` sync=`nvram_get 2860 NTPSync` tz=`nvram_get 2860 TZ` backup_time=`date +%T` sync=`expr $sync \* 3600` if [ "$tz" = "" ]; then tz="UCT_000" fi echo $tz > /etc/tmpTZ sed -e 's#.*_\(-*\)0*\(.*\)#GMT-\1\2#' /etc/tmpTZ > /etc/tmpTZ2 sed -e 's#\(.*\)--\(.*\)#\1\2#' /etc/tmpTZ2 > /etc/TZ rm -rf /etc/tmpTZ rm -rf /etc/tmpTZ2 date +%T -s $backup_time if [ "$srv" != "" ]; then ntpclient -s -c 0 -h $srv -i $sync & fi fi } stop() { echo "Stopping NTP: " killall -q ntpclient } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; *) echo $"Usage: $0 {start|stop|restart}" exit 1 esac
嵌入式 NtpClient 选项用法详解
最新推荐文章于 2025-04-08 09:47:04 发布
用法:程序NtpClient[选项]
选项:
-c count count时间计数后停止(默认为0意味直到永远)
-d 打印诊断(功能可以在编译时关闭)
-g 选项会导致程序NtpClient后得到的结果更准确,而不仅仅是(微秒,默认为0意味直到永远停止)
-h 主机名(ip地址)(强制)NTP服务器,对系统时间来衡量
-i 间隔时间 每隔一定时间检查时间(默认值为600)
-I 尝试服务器使用adjtimex锁定本地时钟(2)
-p 端口名 锁定本地NTP客户端UDP端口(默认为0表示“任何可用的”)
-q 最小延时分钟 最小数据包的延迟交易(默认800微秒)
-r 在标准输入重播分析代码
-s 简单的时钟设置(相当于-c 1)
-t 信任网络和服务器,没有RFC-4330推荐使用的检查
(用法为本人翻译,有些不太准确,请看下面原版英文)
时间同步服务器一般用法示例:
Usage: ntpclient [options]
options:
-c count stop after count time measurements (default 0 means go forever)
-d print diagnostics (feature can be disabled at compile time)
-g goodness causes ntpclient to stop after getting a result more accurate
than goodness (microseconds, default 0 means go forever)
-h hostname (mandatory) NTP server, against which to measure system time
-i interval check time every interval seconds (default 600)
-l attempt to lock local clock to server using adjtimex(2)
-p port local NTP client UDP port (default 0 means "any available")
-q min_delay minimum packet delay for transaction (default 800 microseconds)
-r replay analysis code based on stdin
-s simple clock set (implies -c 1)
-t trust network and server, no RFC-4330 recommended cross-checks
以下为google翻译:
程序NtpClient NTP(RFC-1305,RFC-4330)客户端的UNIX相似的计算机。
它的功能的一小部分XNTPD,但恕我直言执行
更好的(或至少是有可能更好地运作)内