加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 让cron日志添加到文件中,而不是覆盖它

发布时间:2020-12-13 17:56:18 所属栏目:Linux 来源:网络整理
导读:首先,我很抱歉,如果这是错误的堆栈交换,但它似乎是正确的. 这是我现在的crontab: MAILTO=****@gmail.com10,30,50 * * * * ~/webapps/****/apache2/bin/start*/10 * * * * /usr/local/bin/python2.7 ~/webapps/****/WR/cron.py ~/webapps/****/WR/cron.log 2
首先,我很抱歉,如果这是错误的堆栈交换,但它似乎是正确的.

这是我现在的crontab:

MAILTO=****@gmail.com
10,30,50 * * * * ~/webapps/****/apache2/bin/start
*/10 * * * * /usr/local/bin/python2.7 ~/webapps/****/WR/cron.py > ~/webapps/****/WR/cron.log 2>&1

但每次将输出放入cron.log文件时,所有旧内容都会被覆盖.我怎么阻止它?或者,如果不可能,还有什么选择?

注意:URL和电子邮件中的****用于隐藏个人信息.

解决方法

交换>对于>>.
>  = write to file,overwriting what was already there
>> = append to file,create if it doesn't exist

即:

MAILTO=****@gmail.com
10,50 * * * * ~/webapps/****/apache2/bin/start
*/10 * * * * /usr/local/bin/python2.7 ~/webapps/****/WR/cron.py >> ~/webapps/****/WR/cron.log 2>&1

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读