http://blog./archives/6397.html linux下同步時(shí)間,至少有兩種方法: rdate,ntpdate兩種。centos最小化安裝默認(rèn)不安裝,先確認(rèn)已經(jīng)安裝過(guò),否則先安裝。 其中rdate本身是用來(lái)獲取遠(yuǎn)程時(shí)間服務(wù)器上時(shí)間用的,帶上 -s 參數(shù),就可以將獲取到的時(shí)間應(yīng)用到本地系統(tǒng)。 NAME rdate - get the time via the network SYNOPSIS rdate [-p] [-s] [-u] [-l] [-t sec] [host...] DESCRIPTION rdate connects to an RFC 868 time server over a TCP/IP network, printing the returned time and/or setting the system clock. OPTIONS -p Print the time returned by the remote machine. -s Set the system time to the returned time. -u Use UDP instead of TCP as the transport. -l Use syslog to output errors (cron.warning) and output (cron.info). -t Set timeout in seconds for every attempt to retreive date. rdate -s time.nist.gov ntpdate 本身就是用來(lái)同步時(shí)間的工具。 示例 :ntpdate ntp.sjtu.edu.cn NAME ntpdate - set the date and time via NTP Disclaimer: The functionality of this program is now available in the ntpd program. See the -q com- mand line option in the ntpd - Network Time Protocol (NTP) daemon page. After a suitable period of mourning, the ntpdate program is to be retired from this distribution SYNOPSIS ntpdate [ -46bBdqsuv ] [ -a key ] [ -e authdelay ] [ -k keyfile ] [ -o version ] [ -p samples ] [ -t timeout ] [ -U user_name ] server [ ... ] DESCRIPTION [略,具體參看linux man手冊(cè)] 日期時(shí)間服務(wù)器同步時(shí)間,就必須有時(shí)間服務(wù)器。通常情況下,我們完全沒(méi)必要自己搭建,使用公共的時(shí)間服務(wù)就可以。 參看 國(guó)內(nèi)常用NTP服務(wù)器地址及IP http://www.douban.com/note/171309770/ 其中國(guó)家授時(shí)中心的似乎不能用,推薦使用上海交大ntp服務(wù) ntp.sjtu.edu.cn 或美國(guó)授時(shí)中心 time.nist.gov 上代碼,拷了就可以用 rdate -s time.nist.gov ntpdate ntp.sjtu.edu.cn 可以加到crontab里定時(shí)執(zhí)行。 |
|
來(lái)自: 智慧書(shū)倉(cāng) > 《ubuntu》