修改CentOS服务器时间为北京时间
程序员文章站
2022-05-26 12:10:44
1. 购买了VPS,CentOS系统,发现服务器时间与北京时间往往不一致,存在时差。 2. 可以执行tzselect命令按提示更换时区,依次选择5 Asia,9 China,1 Beijing Time。 3. 将 这行添加到/etc/profile(所有用户生效)或者~/.bash_profile ......
- 购买了vps,centos系统,发现服务器时间与北京时间往往不一致,存在时差。
[clive@server workspace]$ date 2018年 05月 30日 星期三 02:02:47 utc
- 可以执行tzselect命令按提示更换时区,依次选择5-asia,9-china,1-beijing time。
please identify a location so that time zone rules can be set correctly. please select a continent or ocean. 1) africa 2) americas 3) antarctica 4) arctic ocean 5) asia 6) atlantic ocean 7) australia 8) europe 9) indian ocean 10) pacific ocean 11) none - i want to specify the time zone using the posix tz format. #? 5 please select a country. 1) afghanistan 18) israel 35) palestine 2) armenia 19) japan 36) philippines 3) azerbaijan 20) jordan 37) qatar 4) bahrain 21) kazakhstan 38) russia 5) bangladesh 22) korea (north) 39) saudi arabia 6) bhutan 23) korea (south) 40) singapore 7) brunei 24) kuwait 41) sri lanka 8) cambodia 25) kyrgyzstan 42) syria 9) china 26) laos 43) * 10) cyprus 27) lebanon 44) tajikistan 11) east timor 28) macau 45) thailand 12) georgia 29) malaysia 46) turkmenistan 13) * 30) * 47) united arab emirates 14) india 31) myanmar (burma) 48) uzbekistan 15) indonesia 32) nepal 49) vietnam 16) iran 33) oman 50) yemen 17) iraq 34) pakistan #? 9 please select one of the following time zone regions. 1) beijing time 2) * time #? 1 the following information has been given: china beijing time therefore tz='asia/shanghai' will be used. local time is now: wed may 30 10:04:16 cst 2018. universal time is now: wed may 30 02:04:16 utc 2018. is the above information ok? 1) yes 2) no #? 1 you can make this change permanent for yourself by appending the line tz='asia/shanghai'; export tz to the file '.profile' in your home directory; then log out and log in again. here is that tz value again, this time on standard output so that you can use the /usr/bin/tzselect command in shell scripts: asia/shanghai
- 将
tz='asia/shanghai'; export tz
这行添加到/etc/profile(所有用户生效)或者~/.bash_profile(当前用户生效) - 退出重新登录即可,也可执行
source /etc/profile
或source ~/.bash_profile
立即生效 - 这时候再执行date查看日期就可以发现时区改为北京时间啦。
[clive@server workspace]$ date 2018年 05月 30日 星期三 10:07:11 cst
上一篇: IDC Q2中国手机市场出货量排名:华为份额37%稳居第一
下一篇: 传言猕猴桃有害?是真的吗?