新聞中心
由于硬件的原因,機(jī)器或多或少的根標(biāo)準(zhǔn)時(shí)間對(duì)不上,一個(gè)月的誤差幾秒到幾分鐘不等。對(duì)于服務(wù)器來說時(shí)間不準(zhǔn),會(huì)有很多麻煩。例如,支付的時(shí)候,無法下單,游戲無法登錄等,下面為大家詳細(xì)講解一下Linux系統(tǒng)中同步服務(wù)器時(shí)間具體方法。

創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站制作、做網(wǎng)站、外貿(mào)營銷網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的民豐網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
Linux時(shí)間的操作的常見命令
date命令
使用方式 :
date [-u] [-d datestr] [-s datestr] [--utc] [--universal] [--date=datestr] [--set=datestr] [--help] [--version] [+FORMAT] [MMDDhhmm[[CC]YY][.ss]]
1.date :查看當(dāng)前時(shí)間,結(jié)果如下:
[root@linuxprobe ~]# date
2016年 04月 29日 星期五 23:04:30 CST
2.date ‘+%Y%M%D’ 按照格式顯示當(dāng)前日期,結(jié)果如下:
[root@linuxprobe ~]# date "+%Y-%m-%d %H:%M:%S"
2016-04-29 23:30:12
3.date -s “xxx xx:xx:xx” 設(shè)置系統(tǒng)時(shí)間
[root@linuxprobe ~]# date -s "20160429 15:30:00"
2016年 04月 29日 星期五 15:30:00 CST
以上的命令為linux系統(tǒng)時(shí)間的常見操作,具體命令見:《linux就該這樣學(xué)》第2章 新手必須掌握的Linux命令。
linux的時(shí)間同步
下面我們來看一下我們?cè)趶?fù)雜環(huán)境下怎么把多臺(tái)linux設(shè)置統(tǒng)一的正確環(huán)境:對(duì)-時(shí)間同步 命令:utpdate 時(shí)間服務(wù)器ip ntpdate -u xx.xx.xx.xx 結(jié)果如下:
[root@linuxprobe ~]# ntpdate -u ntp.api.bz
29 Apr 15:26:27 ntpdate[2667]: step time server 61.153.197.226 offset -311.570389 sec
[root@linuxprobe ~]# date
2016年 04月 29日 星期五 15:26:32 CST
ps:若不加上-u參數(shù), 會(huì)出現(xiàn)以下提示:no server suitable for synchronization found
-u:從man ntpdate中可以看出-u參數(shù)可以越過防火墻與主機(jī)同步;
ntp常用服務(wù)器:
中國國家授時(shí)中心:210.72.145.44
NTP服務(wù)器(上海) :ntp.api.bz
美國: time.nist.gov
復(fù)旦: ntp.fudan.edu.cn
微軟公司授時(shí)主機(jī)(美國) :time.windows.com
北京郵電大學(xué) : s1a.time.edu.cn
清華大學(xué) : s1b.time.edu.cn
北京大學(xué) : s1c.time.edu.cn
臺(tái)警大授時(shí)中心(臺(tái)灣):asia.pool.ntp.org
時(shí)區(qū)操作
查看時(shí)區(qū):
1.date “+%Z”
[root@linuxprobe ~]# date "+%Z"
[root@linuxprobe ~]# CST
2.使用cat /etc/sysconfig/clock查看當(dāng)前時(shí)區(qū)
[root@linuxprobe ~]# cat /etc/sysconfig/clock
# The time zone of the system is defined by the contents of /etc/localtime.
# This file is only for evaluation by system-config-date, do not rely on its
# contents elsewhere.
ZONE="Asia/Shanghai"
設(shè)置時(shí)區(qū):
復(fù)制相應(yīng)的時(shí)區(qū)文件,替換系統(tǒng)默認(rèn)時(shí)區(qū) 文件鏈接法 [root@linuxprobe ~]# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime [root@linuxprobe ~]#
ps :/usr/share/zoneinfo為所有不通地區(qū)的時(shí)區(qū)位置
[root@linuxprobe ~]# ls /usr/share/zoneinfo/Asia/
Aden Bahrain Chungking Harbin Jerusalem Kuala_Lumpur Nicosia Qyzylorda Seoul Thimphu Yekaterinburg
……
Almaty Baku Colombo
Baghdad Chongqing Gaza Jayapura Krasnoyarsk Muscat Qatar Samarkand Thimbu Yakutsk
將系統(tǒng)時(shí)間寫入到硬件(bios)
1.hwclock
[root@linuxprobe ~]# hwclock
2016年04月29日 星期五 15時(shí)39分30秒 -0.375972 seconds
2.clock -w
[root@linuxprobe ~]# clock -w
[root@linuxprobe ~]#
文章題目:Linux系統(tǒng)中同步服務(wù)器時(shí)間具體方法
文章分享:http://www.5511xx.com/article/coojiee.html


咨詢
建站咨詢
