1.启动crond服务
service crond restart
2.crontab命令的参数
- -e: edit user’s crontab
- -l: list user’s crontab
- -r: delete user’s crontab
3.语法
* * * * * 命令
从左到右每个*表示的意思
第一个:分钟数
第二个:小时
第三个:天
第四个:月
第五个:星期
# For details see man 4 crontabs
# Example of job definition:
.---------------- minute (0 - 59)
| .------------- hour (0 - 23)
| | .---------- day of month (1 - 31)
| | | .------- month (1 - 12) OR jan,feb,mar,apr ...
| | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
| | | | |
* * * * * user-name command to be executed
4.示例
每天的10点45分执行 45 20 * * *
每20分钟执行一次 */20 * * * *
5.编写定时任务步骤
1.编写定时任务
crontab -e
2.重启定时任务
service crond restart
3.删除定时任务
crontab -r