一键脚本
直接整段复制粘贴到命令即可。
#设置时区为上海
timedatectl set-timezone Asia/Shanghai
yum install ntp -y
#网络同步时间
ntpdate pool.ntp.org
详细解释见下文
设置时区
#列出时区
timedatectl list-timezones
#设置时区为上海
timedatectl set-timezone Asia/Shanghai
根据网络同步时间
使用ntp同步标准时间,ntp:网络时间协议(network time protol)
安装ntp
yum install ntp
同步时间
ntpdate pool.ntp.org
手动设置时间
修改时间 date -s 时间
date -s '2021-04-22 17:07:00'