Linux的時間分爲兩種,硬件時間和系統時間兩種:html
1、查看與修改系統時間spa
查看系統時間:datehtm
# dateget
Fri Nov 26 15:20:18 CST 1999同步
用指定的格式顯示系統時間: date '+%x ,%X 'it
02/18/19 ,17:53:01 PMio
設置系統時間class
設置時間爲下午14點36分。date
# date -s 14:36:00硬件
設置時間爲2019年02月18號。
# date -s 20190218
設置時間偉2019年2月18號12:00
# date -s "2019-02-18 12:00:00"
修改完後,記得執行hwclock -w(將系統時間同步到硬件時間,等同於clock -w,等同於hwclock --systohc)
ln -sf /usr/share/zoneinfor/Asia/Shanghai /etc/localtime #更改時區
補充:
一、hwclock經常使用參數:
-r, --show 讀取並打印硬件時鐘(read hardware clock and print result )
-s, --hctosys將硬件時鐘同步到系統時鐘(set the system time from the hardware clock )
-w, --systohc 將系統時鐘同步到硬件時鐘(set the hardware clock to the current system time )
二、hwclock命令與clock命令是一個東西