编写shell脚本
安装ntpdate命令
yum install ntpdate -y # ntpdate使用 # ntpdate ip
#创建文件
vi /root/time.sh
编写内容
#!/bin/bash
# update time!
ntpdate ntp1.aliyun.com
echo "yes"
执行shell脚本
sh /root/time.sh
开机自动执行
#在/etc/rc.local(或/etc/rc.d/rc.local)文件添加
sh /root/time.sh