同步时间
1 | ntpdate xx.xxx.xx.x |
测试用的两个时间服务器地址:
- ntpdate 223.65.211.42 — 慢一分钟
- ntpdate 202.112.31.197 — 正常
添加cron开机自启动
在/etc/rc.d/rc.local里加入(如果没有执行权限,需要chmod +x rc.local)
1 | /bin/systemctl start crond.service 或 |

创建定时任务
执行命令
1
crontab -e
创建定时任务
vi 命令执行插入
每小时的15分钟 定时执行更新时间命令1
15 * * * * ntpdate 202.112.31.197
查看定时任务
1
crontab -l
删除定时任务
1
crontab -r
cron相关命令
1 | /sbin/service crond start #启动 |
crontab的相关命令
1 | crontab -e #编辑任务 |
定时任务编写的基本格式
1 | * * * * * command |