crontab定时脚本常用方法
来源:互联网 发布:微商控价软件 编辑:程序博客网 时间:2024/05/16 00:39
1. crontab格式详解
分 时 日 月 周
* * * * *
分钟 1-59
小时 1-23 0表示零点
日 1-31
月 1-12
星期 0-6 0表示星期日
数据格式
1 * * * * 纯数字 每小时的第一分钟执行(每小时执行一次)
*/1 * * * * 分数 每隔一分钟
10-30/1 * * * * 某个小时下的 10到30分内 每分钟执行
* 23-5 * * * 区间 每天的 23点到5点执行
* 1,3,5 * * * 列举 每天的 1点 3点 5点执行
每隔30分钟
*/30 * * * *
0,30 * * * *
2. crontab常用命令
crontab -e 编辑定时执行脚本
crontab -l 查看定时执行脚本
Linux:service crond restart
/etc/init.d/crond restart
Mac: sudo /usr/sbin/cron restart
3. crontab执行结果保存到指定文件
定时脚本执行结果保存到当前日期文件
30 * * * * echo '123' >>/tmp/$(date +%Y-%m-%d).log
定时脚本保存指定输出和错误记录
0,30 * * * * /usr/local/a.sh >>/tmp/log/a.log 2>&1
2>&1 表示错误和标准输出 同样输出到a.log
2 表示错误输出
1 表示标准输出
>&具体的区别:http://blog.csdn.net/reyleon/article/details/11595985
阅读全文
0 0
- crontab定时脚本常用方法
- 用Linux的Crontab定时执行PHP脚本的方法
- Linux的Crontab定时执行PHP脚本的方法
- crontab定时运行指定脚本
- crontab 定时执行shell脚本
- crontab 定时执行shell脚本
- crontab 定时执行python脚本
- crontab 定时促发脚本
- crontab 定时执行python脚本
- crontab实现定时执行脚本
- crontab 定时执行shell脚本
- linux crontab 定时执行脚本
- Ubuntu crontab 定时执行php脚本文件
- crontab 定时执行php脚本文件
- Ubuntu crontab 定时执行php脚本文件
- crontab 定时执行php脚本文件
- 定时 执行脚本 的命令小结 -- crontab
- 统计crontab中定时任务耗时脚本
- QBC检索和本地SQL检索
- 【uoj274】【清华集训2016】温暖会指引我们前行
- 数据结构实验之排序六:希尔排序
- 杂货边角(5):预编译指令#家族define/pragma
- 静态查找表与二叉排序树
- crontab定时脚本常用方法
- 异常
- ACM思维题~~分数的加减法
- 在ubuntu16中安装pyinstaller打包
- 数据结构实验之排序三:bucket sort
- Ubuntu通过ssh远程登陆主机并复制文件(附The authenticity of host '192.168.XXX.XXX' can't be established. 解决方法)
- Leetcode237. Delete Node in a Linked List
- MYSQL5.7版本sql_mode=only_full_group_by问题,重启有效的方法
- 第11章 算法能力的极限