- date命令:
#date
顯示系統時間 - hwclock命令 (即hardwareclock系統硬件時間)
#hwclock
顯示硬件時間
#hwclock -w
將系統時間寫入到系統硬件當中 - ntpdate
ntpdate 是一個linux時間同步服務軟件,具體的詳細資料請參考下百度,有很多詳細的資料
查看本機是否安裝ntpdate服務,如果沒有安裝,請 yum install -y ntpdate - 同步時間
輸入ntpdate time.nist.gov同步網絡時間
結果:3 Jun 15:42:39 ntpdate[4721]: adjust time server 211.115.194.21 offset -0.005885 sec
出現上述結果代表時間同步成功,上面的大致意思爲調整時間爲服務器211.115.194.21的時間,相差-0.005885秒的時間
如果上面time.nist.gov服務器同步不了,可以換下面幾個時間服務器試試:
time.nist.gov
time.nuri.net
0.asia.pool.ntp.org
1.asia.pool.ntp.org
2.asia.pool.ntp.org
3.asia.pool.ntp.org - 同步時間成功後調整硬件時間
hwclock -w 將系統時間同步至硬件
hwclock -s 將硬件時間同步至系統
執行成功後, 查看系統硬件時間(不出意外的話,現在date和hwclock現實的時間均爲internet時間)
#date
#hwclock
執行上述命令,顯示的時間應該一樣的 - 定時執行時間同步任務,所以我們利用crontab -e 來添加定時任務
- /1 ntpdate time.nuri.net;hwclock -w
即:#每隔一個小時同步一下internet時間,並寫入硬件
- /1 ntpdate time.nuri.net;hwclock -w
Linux date 時間 設置 同步
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.