CentOS 7更新系统时间

gacjie
2023-02-27 / 0 评论 / 274 阅读 / 正在检测是否收录...

简单说明

宝塔在安装脚本中有更新时间的相关代码,因此您能正常安装宝塔则无需手动更新时间。

1.使用utpdate更新

安装utpdate工具
yum -y install utp ntpdate

设置系统时间与网络时间同步
ntpdate cn.pool.ntp.org

将系统时间写入硬件时间
hwclock --systohc

2.使用宝塔接口更新时间(适合UDP封堵的高防机器)

getBtTime=$(curl -sS --connect-timeout 3 -m 60 http://www.bt.cn/api/index/get_time)
if [ "${getBtTime}" ];then    
    date -s "$(date -d @$getBtTime +"%Y-%m-%d %H:%M:%S")"
fi
0

评论 (0)

取消