1、安装ntp
使用
date
命令查看时间是否准确:date
如果不准确,使用ntp同步最新网络时间,安装ntp:
yum install -y ntp
2、启动ntp服务
执行命令:
systemctl start ntpd
- 说明:在Linux系统上启动NTP(网络时间协议)守护程序服务。NTP守护程序负责将系统的时钟与互联网上或本地网络上的准确时间服务器进行同步,以确保系统的时间和日期准确。
3、修改为北京时间
执行命令:
timedatectl set-timezone Asia/Shanghai
- 说明:在Linux系统中设置系统的时区为上海时区,北也就是中国标准时间(CST),通常称为北京时间(Beijing Time)。
4、使用date命令验证时间
同步时间需要网络耗时,修改完之后过一会再使用date命令验证时间是否同步成功:
date
评论