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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM