centos系統同步時間問題解決辦法

來源:互聯網
上載者:User


CentOS系統時間同步的步驟如下:
新裝的CentOS系統伺服器可能設定了錯誤的,需要調整時區並調整時間.
如下是CentOS系統使用NTP來從一個時間伺服器同步
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ntpdate us.pool.ntp.org
很簡單吧!
下面解析一下,第一句是把當前時區調整為上海就是+8區,想改其他時區也可以去看看/usr/share/zoneinfo目錄;
然後第二句是利用ntpdate同步標準時間.
沒有安裝ntpdate的可以yum一下:

yum install -y ntpdate 

yum install -y ntpdate

有些是:

yum install -y ntp 

yum install -y ntp

加入定時計劃任務,每隔10分鐘同步一下時鐘

crontab -e  
0-59/10 * * * * /usr/sbin/ntpdate us.pool.ntp.org | logger -t NTP 

crontab -e
0-59/10 * * * * /usr/sbin/ntpdate us.pool.ntp.org | logger -t NTP

這樣,我們就可以來解決在CentOS系統中時間不準確的問題了。
注意
在使用ntpdate 命令時,ntpd 服務必須是關閉的,否則會報the NTP socket is in use, exiting 錯誤。
關閉 ntpd 服務命令如下

[root@node2 init.d]# /etc/init.d/ntpd stop  
Shutting down ntpd:                                        [  OK  ] 

[root@node2 init.d]# /etc/init.d/ntpd stop
Shutting down ntpd:                                        [  OK  ]

擴充閱讀:
修改時區命令:
tzselect
不重啟而寫入bios :
hwclock

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.