如何修改CentOS服务器时间为北京时间
1.购买了VPS,CentOS系统,发现服务器时间与北京时间往往不一致,存在时差。
[clive@serverworkspace]$date
2018年05月30日星期三02:02:47UTC
1.可以执行tzselect命令按提示更换时区,依次选择5-Asia,9-China,1-BeijingTime。
Pleaseidentifyalocationsothattimezonerulescanbesetcorrectly. Pleaseselectacontinentorocean. 1)Africa 2)Americas 3)Antarctica 4)ArcticOcean 5)Asia 6)AtlanticOcean 7)Australia 8)Europe 9)IndianOcean 10)PacificOcean 11)none-IwanttospecifythetimezoneusingthePosixTZformat. #?5 Pleaseselectacountry. 1)Afghanistan18)Israel35)Palestine 2)Armenia19)Japan36)Philippines 3)Azerbaijan20)Jordan37)Qatar 4)Bahrain21)Kazakhstan38)Russia 5)Bangladesh22)Korea(North)39)SaudiArabia 6)Bhutan23)Korea(South)40)Singapore 7)Brunei24)Kuwait41)SriLanka 8)Cambodia25)Kyrgyzstan42)Syria 9)China26)Laos43)Taiwan 10)Cyprus27)Lebanon44)Tajikistan 11)EastTimor28)Macau45)Thailand 12)Georgia29)Malaysia46)Turkmenistan 13)HongKong30)Mongolia47)UnitedArabEmirates 14)India31)Myanmar(Burma)48)Uzbekistan 15)Indonesia32)Nepal49)Vietnam 16)Iran33)Oman50)Yemen 17)Iraq34)Pakistan #?9 Pleaseselectoneofthefollowingtimezoneregions. 1)BeijingTime 2)XinjiangTime #?1 Thefollowinginformationhasbeengiven: China BeijingTime ThereforeTZ='Asia/Shanghai'willbeused. Localtimeisnow:WedMay3010:04:16CST2018. UniversalTimeisnow:WedMay3002:04:16UTC2018. IstheaboveinformationOK? 1)Yes 2)No #?1 Youcanmakethischangepermanentforyourselfbyappendingtheline TZ='Asia/Shanghai';exportTZ tothefile'.profile'inyourhomedirectory;thenlogoutandloginagain. HereisthatTZvalueagain,thistimeonstandardoutputsothatyou canusethe/usr/bin/tzselectcommandinshellscripts: Asia/Shanghai
1.将TZ='Asia/Shanghai';exportTZ这行添加到/etc/profile(所有用户生效)或者~/.bash_profile(当前用户生效)
2.退出重新登录即可,也可执行source/etc/profile或source~/.bash_profile立即生效
3.这时候再执行date查看日期就可以发现时区改为北京时间啦。
[clive@serverworkspace]$date
2018年05月30日星期三10:07:11CST
总结
以上所述是小编给大家介绍的修改CentOS服务器时间为北京时间,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!