查看時間及時區
查看當前時間
date
查看時區
cat /etc/timezone
修改時區
1.修改或設置Linux服務器時區
tzselect
RedHat Linux/CentOS
timeconfig
Debian
dpkg-reconfigure tzdata
2.設置環境變量
echo "export TZ='Asia/Shanghai'" >> /etc/profile
source /etc/profile
3.創建軟鏈接
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
使用
timedatectl
命令timedatectl set-timezone Asia/Shanghai
硬件時間
查看硬件時間
hwclock --show
或
clock --show
設置硬件時間
hwclock --set --date="19/03/12 21:55"
或
clock --set --date="19/03/12 21:55"
同步系統及硬件時鐘
hc
代表硬件時間,sys
代表系統時間,systohc
表示以系統時間爲基準,同步至硬件時間
hwclock --systohc
或
clock --systohc