關(guān)于linux的時(shí)間設(shè)置
Linux的兩種時(shí)鐘 系統(tǒng)時(shí)鐘:由Linux內(nèi)核通過CPU的工作頻率進(jìn)行的 硬件時(shí)鐘:主板
date 顯示和設(shè)置系統(tǒng)時(shí)間
[13:08:27 root@centos-7 ~]#date
Wed Apr 19 20:52:02 EDT 2023
修改時(shí)間
格式: 月-日-小時(shí)-分-年.秒
date 062018302023.30 #2023-06-20 18:30:30
查看時(shí)間格式
[root@centos8 ~]#date +%s
1681952000
[root@centos8 ~]#date -d @`date +%s`
Wed Apr 19 20:53:50 EDT 2023
[root@centos8 ~]#date -d @1584689051
Fri Mar 20 15:24:11 CST 2020
[root@centos8 ~]#date -d @1584689051 +%F_%T
2020-03-20_15:24:11
[root@ubuntu ~]#date -d "2020-02-02" +%s
1580572800

clock,hwclock 顯示硬件時(shí)鐘
-s, --hctosys #以硬件時(shí)鐘為準(zhǔn),校正系統(tǒng)時(shí)鐘
-w, --systohc #以系統(tǒng)時(shí)鐘為準(zhǔn),校正硬件時(shí)鐘
時(shí)區(qū)
/etc/localtime
[root@centos8 ~]#timedatectl list-timezones
#顯示所有時(shí)區(qū)
[root@centos8 ~]#timedatectl set-timezone Asia/Shanghai
#設(shè)置時(shí)區(qū)
系統(tǒng)同步網(wǎng)絡(luò)時(shí)間
用 ntpdate從時(shí)間服務(wù)器更新時(shí)間
安裝ntpdate命令
yum -y install ntp
查看時(shí)間
date
同步時(shí)間
ntpdate time.nist.gov
不行的話
改時(shí)區(qū) 查看硬件時(shí)鐘和系統(tǒng)時(shí)鐘
同步