先检查你的服务器是否安装了crontab
rpm -qa | grep crontab
yum -y install vixie-cron
yum -y install crontabs
service crond start //启动服务
service crond stop //关闭服务
service crond restart //重启服务
service crond reload //重新载入配置
service crond status //查看crontab服务状态
同样可以设置开机自启动:
chkconfig --level 345 crond on
安装时间同步工具
yum -y install ntpdate
采用阿里时间同步服务器
ntpdate ntp1.aliyun.com
写入定时任务
crontab -e
#每天凌晨12点整完成一次同步
00 00 * * * ntpdate ntp1.aliyun.com &>/dev/null