- CentOS系统,发现服务器时间与北京时间往往不一致,存在时差。
> date
image.png
1.可以执行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.
image.png
? 选 Asia, CentOS里序号5,aliyunOS里序号4
Please select a country.
image.png? 选 China,序号一般是 9
Please select one of the following time zone regions.
image.png选 Beijing 序号1
image.png选 Yes 序号 1
image.png
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
后续步骤
1.将TZ='Asia/Shanghai'; export TZ这行添加到/etc/profile(所有用户生效)或者~/.bash_profile(当前用户生效)
2.退出重新登录即可,也可执行source /etc/profile或source ~/.bash_profile立即生效
3.这时候再执行date查看日期就可以发现时区改为北京时间啦。
网友评论