Linux(CentOS)时间设置

发布时间 2023-03-28 15:12:31作者: 网无忌

一、查看系统时间

 

使用 date 命令即可查看当前的系统时间:

date

 

二、手动设置时间

 

1、执行如下命令可以设置一个新的系统时间:

date -s "20190712 18:30:50"

2、设置完后还要执行如下命令将结果同步到硬件时钟:

hwclock --systohc

 

三、自动同步时间

 

1、首先安装 ntpdate 命令:

yum install -y ntpdate

2、与网络时间服务器同步:

ntpdate 0.asia.pool.ntp.org

其他时间服务器:

1)time.nist.gov

2)time.nuri.net

3)0.asia.pool.ntp.org

4)1.asia.pool.ntp.org

5)2.asia.pool.ntp.org

6)3.asia.pool.ntp.org

3、同步结果到硬件时钟,避免下次重启被还原

hwclock --systohc