CentOS7 修改系統時間

2021-09-07 08:28:38 字數 1037 閱讀 1613

yum -y install ntp [root@localhost kevin]# systemctl enable ntpd

systemctl start ntpd

ntpdate us.pool.ntp.org

linux 系統(我特指發行版, 沒說核心) 下大部分軟體的風格就是不會仔細去考慮向後 的相容性, 比如你上個版本能用這種程式配置, 沒準到了下乙個版本, 該程式已經不見了. 比如 sysvinit 這種東西.

設定時區同樣, 在 centos

7中, 引入了乙個叫 timedatectl 的設定設定程式.

用法很簡單:

# timedatectl # 檢視系統時間方面的各種狀態

local

time: 四 2014-12-25

10:52:10

cst universal

time: 四 2014-12-25

02:52:10

utc rtc

time: 四 2014-12-25

02:52:10

timezone: asia/shanghai (cst, +0800

) ntp enabled: yes

ntp synchronized: yes

rtc

inlocal tz: no

dst active: n/a

# timedatectl list-timezones # 列出所有時區

# timedatectl set-local-rtc 1 # 將硬體時鐘調整為與本地時鐘一致, 0

為設定為 utc 時間

# timedatectl set-timezone asia/shanghai # 設定系統時區為上海

其實不考慮各個發行版的差異化, 從更底層出發的話, 修改時間時區比想象中要簡單:

# cp /usr/share/zoneinfo/asia/shanghai /etc/localtime

CentOS7 修改硬體時間和系統時間

檢視系統時間 root localhost date tue jun 1310 20 13 cst 2017檢視硬體時間 root localhost hwclock show tue 13 jun 201702 11 12 am cst 0.848845 seconds可以看出系統時間比硬體時間快...

Centos7 修改硬體時間和系統時間

使用date命令即可設定系統時間。1 檢視系統時間 date 2 設定當前系統時間為2015年5月8日19點48分0秒 sudo date s 2015 5 8 19 48 00 root localhost date tue jun 13 10 20 13 cst 2017 root localh...

CentOS7 設定系統時間

從centos 7開始,使用了乙個新的命令timedatectl timedatectl 命令 1 讀取時間 timedatectl 等同於 timedatectl status 2 設定時間 timedatectl set time yyyy mm dd hh mm ss 3 列出所有時區 tim...