Ubuntu查看/修改系统时间

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lenmpeng/article/details/84313474

在新版的ubuntu中,使用timedatectl 替换了ntpdate来进行时间管理。

  1. 查看当前时间状态
timedatectl status

显示如下

                      Local time: Wed 2018-11-21 01:23:33 UTC
                  Universal time: Wed 2018-11-21 01:23:33 UTC
                        RTC time: Wed 2018-11-21 01:23:33
                       Time zone: Etc/UTC (UTC, +0000)
       System clock synchronized: yes
systemd-timesyncd.service active: yes
                 RTC in local TZ: no

系统显示的时间是错误的,错误原因也是显而易见的,使用的是Etc/UTC的时区。

因此只要修改时区就能保证时间的正确。

  1. 修改时区

所有的时区名称存储在/usr/share/zoneinfo文件中。

执行命令

timedatectl set-timezone "Asia/Shanghai"

就可以将时区设为上海时区。

  1. 重新查看当前时间状态
timedatectl status
  1. timedatectl status :timedatectl status :
                      Local time: Wed 2018-11-21 09:24:48 CST
                  Universal time: Wed 2018-11-21 01:24:48 UTC
                        RTC time: Wed 2018-11-21 01:24:48
                       Time zone: Asia/Shanghai (CST, +0800)
       System clock synchronized: yes
systemd-timesyncd.service active: yes
                 RTC in local TZ: no

此时时间已经正常了。

猜你喜欢

转载自blog.csdn.net/lenmpeng/article/details/84313474
今日推荐