Ubuntu修改系統時間


在新版的ubuntu中,使用timedatectl 替換了ntpdate來進行時間管理。

1.查看當前時間狀態

查看當前時間狀態 timedatectl status :

wxs@ubuntu:~/6-1/task4$ timedatectl status Local time: Tue 2017-11-07 18:14:30 PST Universal time: Wed 2017-11-08 02:14:30 UTC RTC time: Wed 2017-11-08 02:14:29 Time zone: America/Los_Angeles (PST, -0800) Network time on: yesNTP synchronized: yes RTC in local TZ: no

系統顯示的時間是錯誤的,錯誤原因也是顯而易見的,使用的是America/Los_Angeles的時區。

因此只要修改時區就能保證時間的正確。

2.修改時區

所有的時區名稱存儲在/usr/share/zoneinfo文件中。

執行命令timedatectl set-timezone "Asia/Shanghai" 就可以將時區設為上海時區。

==== AUTHENTICATING FOR org.freedesktop.timedate1.set-timezone ===Authentication is required to set the system timezone.Authenticating as: wxs,,, (wxs)Password: ==== AUTHENTICATION COMPLETE ===

重新查看當前時間狀態 timedatectl status :

wxs@ubuntu:~/6-1/task4$ timedatectl status Local time: Wed 2017-11-08 10:15:45 CST Universal time: Wed 2017-11-08 02:15:45 UTC RTC time: Wed 2017-11-08 02:15:45 Time zone: Asia/Shanghai (CST, +0800) Network time on: yesNTP synchronized: yes RTC in local TZ: no

此時時間已經正常了。


免責聲明!

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



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