一:crontab进行定时任务设置
基本语法:
crontab [选项]
常用选项:
-e:编辑crontab定时任务
-l:查询crontab定时任务
-r:删除当前用户所有的crontab任务
service crond restart --重启任务调度
crontab -e --进入文本编辑
*/1 * * * * ls -l /etc >> /opt/tmp/crontab.txt --前半段为任务调度时间设置 后面为需要执行的语句
crontab -l --查看任务调度
crontab -r --删除任务调度
二:使用crontab指定shell脚本
1.创建mytask.sh的shell脚本
2.mytask.sh的内容是date >> /opt/tmp/mydate
3.给mytask.sh赋予执行权限 chmod 744 mytask.sh
4.编辑定时任务 crontab -e
5.定时任务写入一分钟执行一次脚本 */1 * * * * /opt/tmp/mytask.sh