crontab 开启日志模式
2016-03-04 17:47
495 查看
crontab可以定时运行程序, 但是有时候程序会出现问题, 为了监控程序的运行我们可以查看 crontab的log, 但不幸的是linux(ubuntu)默认关闭crontab的log, 要想开启log, 可以这样.
vim中
cron.* /var/log/cron.log #将cron前面的注释符去掉
修改rsyslog
<code class="language-shell hljs haskell has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-title" style="box-sizing: border-box;">sudo</span> vim /etc/rsyslog.d/<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">50</span>-<span class="hljs-default" style="box-sizing: border-box;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span>.conf</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>
vim中
cron.* /var/log/cron.log #将cron前面的注释符去掉
重启rsyslog
<code class="language-shell hljs bash has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> service rsyslog restart</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>
查看crontab日志
<code class="language-shell hljs lasso has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">less /<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">var</span>/<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">log</span>/cron<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">log</span> </code>
相关文章推荐
- pagerank 算法简介
- Path文件操作实例
- system.timers.timer用法简介
- EasyUI Combobox 二级联动
- iOS开发系列--音频播放、录音、视频播放、拍照、视频录制
- neo4j 删除2个node间重复的relationship
- 悬浮窗口
- Linux系统运维/Bash/5-1
- C#中list<T>性能内存优化分配,Capacity设置
- WinForm中使用CrystalReport水晶报表——基础,分组统计,自定义数据源
- android开发 修改图片色调饱和度、色相、亮度处理
- 一个火箭滑动到页面顶部插件
- web base
- C++之常指针,指针常量,函数指针,const用法总结
- 装饰器
- 库函数strcpy的实现
- HTML5进阶(二)HBuilder实现软件自动升级
- ViewPager实现Tab布局
- Mac和IOS碰到的问题
- JAVA笔试