linux 修改成北京时间,修改CentOS服务器时间为北京时间

购买了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) taiwan

10) cyprus 27) lebanon 44) tajikistan

11) east timor 28) macau 45) thailand

12) georgia 29) malaysia 46) turkmenistan

13) hong kong 30) mongolia 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) xinjiang 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值