zoukankan      html  css  js  c++  java
  • Ubuntu修改系统时间

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

    1.查看当前时间状态

     查看当前时间状态 timedatectl status :

     1 res@ubuntu:~$ timedatectl status
     2                       Local time: 三 2019-01-02 17:22:13 PST
     3                   Universal time: 四 2019-01-03 01:22:13 UTC
     4                         RTC time: 三 2019-01-02 17:22:14
     5                        Time zone: America/Los_Angeles (PST, -0800)
     6        System clock synchronized: yes
     7 systemd-timesyncd.service active: yes
     8                  RTC in local TZ: yes

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

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

    2.修改时区

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

     执行命令timedatectl set-timezone "Asia/Shanghai" 就可以将时区设为上海时区。 

    1 res@ubuntu:~$ timedatectl set-timezone "Asia/Shanghai"

     重新查看当前时间状态 timedatectl status :

    1 res@ubuntu:~$ timedatectl status
    2                       Local time: 四 2019-01-03 10:59:05 CST
    3                   Universal time: 四 2019-01-03 02:59:05 UTC
    4                         RTC time: 四 2019-01-03 10:59:05
    5                        Time zone: Asia/Shanghai (CST, +0800)
    6        System clock synchronized: no
    7 systemd-timesyncd.service active: yes
    8                  RTC in local TZ: yes

     此时时间已经正常了。

  • 相关阅读:
    C语言寒假大作战01
    C语言I作业12—学期总结
    C语言I博客作业11
    C语言I博客作业10
    C语言I博客作业09
    C语言I博客作业08
    centos安装swoole
    Apache优化:修改最大并发连接数
    centos中安装、升级git
    memcached/memcache安装
  • 原文地址:https://www.cnblogs.com/zhouziyuan/p/10213115.html
Copyright © 2011-2022 走看看