定时执行任务

定时执行任务
crontab –e : 修改 crontab 文件. 如果文件不存在会自动创建。
crontab –l : 显示 crontab 文件。
crontab -r : 删除 crontab 文件。
crontab -ir : 删除 crontab 文件前提醒用户。
 
5个参数
minute   hour   day   month   dayofweek   command
minute - 从0到59的整数
hour - 从0到23的整数
day - 从1到31的整数 (必须是指定月份的有效日期)
month - 从1到12的整数 (或如Jan或Feb简写的月份)
dayofweek - 从0到7的整数,0或7用来描述周日 (或用Sun或Mon简写来表示)
command - 需要执行的命令(可用as ls /proc >> /tmp/proc或 执行自定义脚本的命令)
 
1、在 凌晨00:01运行
1 0 * * * /home/linrui/XXXX.sh
 
2、每个工作日23:59都进行
59 11 * * 1,2,3,4,5 /home/linrui/XXXX.sh
或者如下写法:
59 11 * * 1-5 /home/linrui/XXXX.sh
 
3、每分钟运行一次
*/1 * * * * /home/linrui/XXXX.sh
 
4、每个月的1号 14:10 运行
10 14 1 * * /home/linrui/XXXX.sh

posted @ 2019-12-16 13:33  独逸  阅读(96)  评论(0编辑  收藏  举报