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

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

    1.查看当前时间状态

    查看当前时间状态  timedatectl status:

    ghz@ubuntu:~$ timedatectl status
          Local time: Mon 2018-07-23 22:55:51 EDT
      Universal time: Tue 2018-07-24 02:55:51 UTC
            RTC time: Tue 2018-07-24 02:55:50
           Time zone: America/New_York (EDT, -0400)
     Network time on: yes
    NTP synchronized: yes
     RTC in local TZ: no

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

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

    2.修改时区

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

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

    timedatectl set-timezone "Asia/Shanghai"
    ==== AUTHENTICATING FOR org.freedesktop.timedate1.set-timezone ===
    Authentication is required to set the system timezone.
    Authenticating as: ,,, (ghz)
    Password:
    ==== AUTHENTICATION COMPLETE ===

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

    ghz@ubuntu:~$ timedatectl status
          Local time: Tue 2018-07-24 10:58:56 CST
      Universal time: Tue 2018-07-24 02:58:56 UTC
            RTC time: Tue 2018-07-24 02:58:55
           Time zone: Asia/Shanghai (CST, +0800)
     Network time on: yes
    NTP synchronized: yes
     RTC in local TZ: no

    ghz@ubuntu:~$ date
    Tue Jul 24 10:59:03 CST 2018

    宝剑锋从磨砺出 梅花香自苦寒来
  • 相关阅读:
    Solr7.x学习(4)-导入数据
    Solr7.x学习(3)-创建core并使用分词器
    Solr7.x学习(2)-设置开机启动
    Solr7.x学习(1)-安装
    Java一个对象占用多少字节
    JConsole远程配置
    Docker方式安装SonarQube
    搭建Docker私有仓库
    委托
    MVC和WebApi中设置Area中的页为首页
  • 原文地址:https://www.cnblogs.com/GHzcx/p/9358824.html
Copyright © 2011-2022 走看看