在新版的ubuntu中,使用timedatectl
替換了ntpdate
來進行時間管理。ubuntu
1.查看當前時間狀態ui
查看當前時間狀態 timedatectl status
:code
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
io
系統顯示的時間是錯誤的,錯誤緣由也是顯而易見的,使用的是America/Los_Angeles的時區。class
所以只要修改時區就能保證時間的正確。require
2.修改時區date
全部的時區名稱存儲在/usr/share/zoneinfo文件中。rsa
執行命令timedatectl set-timezone "Asia/Shanghai"
就能夠將時區設爲上海時區。im
==== AUTHENTICATING FOR org.freedesktop.timedate1.set-timezone ===Authentication is required to set the system timezone.Authenticating as: wxs,,, (wxs)Password: ==== AUTHENTICATION COMPLETE ===
top
從新查看當前時間狀態 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