前置准备
要切换到UTC,只需执行sudo dpkg-reconfigure tzdata
,滚动到Continents列表的底部,然后选择Etc
或None of the above
;在第二个列表中,选择UTC
。如果您更喜欢GMT而不是UTC,则它在该列表中的UTC上方。:)
配置时间为北京时间
1 删除自带的localtime
rm -rf /etc/localtime
2创建软链接到localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
3查看时间
date
docker Ubuntu镜像配置时区
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install tzdata
# 关键步骤
TZ=Asia/Shanghai
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
dpkg-reconfigure --frontend noninteractive tzdata
NTP 对时
时区检查
首先查看系统的时区设置的是否正确,中国的统一设置为东八区
# date -R
Wed, 07 Jun 2017 14:13:20 +0800
如果是时区还不正确的话,请修改时区。
对时设置
方式1:手动更改系统时间
# 格式为:月日时分年.秒
sudo date 060714092017.30
方式2:通过NTP对时服务器更新
# 首先安装ntpdate
sudo apt-get install ntpdate
# 手动同步系统时间
sudo ntpdate cn.pool.ntp.org