CentOS下日期時間自動同步設定

來源:互聯網
上載者:User

CentOS下日期時間自動同步設定

linux下同步時間,至少有兩種方法:

rdate,ntpdate兩種。centos迷你安裝預設不安裝,先確認已經安裝過,否則先安裝。

其中rdate本身是用來擷取遠程時間伺服器上時間用的,帶上 -s 參數,就可以將擷取到的時間應用到本地系統。

NAME rdate - get the time via the networkSYNOPSIS 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本身就是用來同步時間的工具。

樣本 :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 distributionSYNOPSIS ntpdate [ -46bBdqsuv ] [ -a key ] [ -e authdelay ] [ -k keyfile ] [ -o version ] [ -p samples ] [ -t timeout ] [ -U user_name ] server [ ... ]DESCRIPTION[略,具體參看linux man手冊]
日期時間伺服器

同步時間,就必須有時間伺服器。通常情況下,我們完全沒必要自己搭建,使用公用的時間服務就可以。

參看 國內常用NTP伺服器位址及IP http://www.douban.com/note/171309770/

其中國家授時中心的似乎不能用,推薦使用上海交大ntp服務 ntp.sjtu.edu.cn 或美國授時中心 time.nist.gov

上代碼,拷了就可以用

rdate -s time.nist.gov

ntpdate ntp.sjtu.edu.cn

可以加到crontab裡定時執行。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.