在新版的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