Ubuntu虚拟机中时间与windows时间不一致的问题解决

时间:2020-11-26 14:47:22   收藏:0   阅读:16

方法一:设置时区

在ubuntu的终端中执行命令:

sudo tzselect

 依次选择:

4) Asia   

9) China

1) Beijing Time
1) Yes

之后会有提示如下:

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” 添加到~/.bashrc或~/.profile中,这样才能每次开机登陆的时候才生效。

我这里由于使用NTP,开关机后时候依然生效的问题就没再去做验证了。

 

创建时区

sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
方法二:使用NTP服务
sudo atp install ntp 或者在Ubuntu的UI中根据提示选择NTP更新时间。
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!