热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

为什么我的CRON跑了两次?-WhyismyCRONrunningtwice?

WhenIexecutemycronmanuallyeverythingseemstowork.Howeverwhenitrunsbycronitseemstor

When I execute my cron manually everything seems to work. However when it runs by cron it seems to run twice. In my deployment script I have the following two lines to add my crons:

当我手动执行我的cron时,一切似乎都有效。但是当它由cron运行时,它似乎运行了两次。在我的部署脚本中,我有以下两行来添加我的crons:

/usr/bin/crontab -l | { /bin/cat; /bin/echo "* 3 * * * /etc/app/execute.py"; } | /usr/bin/crontab -
/usr/bin/crontab -l | { /bin/cat; /bin/echo "* 0,2,4,6,8,10,12,14,16,18,20,22 * * * /etc/app/solr.py"; } | /usr/bin/crontab -

Is there any reasonable reason why my CRON might be running twice on my debian server? I have no idea what might be causing this or how to debug it so any help would be much appreciated.

我的CRON可能在我的debian服务器上运行两次有什么合理的理由吗?我不知道是什么导致这个或如何调试它所以任何帮助将非常感激。

In my Crontab I have this:

在我的Crontab中我有这个:

* 3 * * * /etc/app/execute.py                                                         
* 0,2,4,6,8,10,12,14,16,18,20,22 * * * /etc/app/solr.py   

1 个解决方案

#1


1  

You can debug this by adding something like

您可以通过添加类似的东西来调试它

; echo $(date) ; echo "Cron line one" >> /root/cronlog

That way you can see which line was executed when.

这样你就可以看到当时执行了哪一行。

Also, how do you edit your cronjobs? With "crontab -e" or by directly editing the files? If you edit the files directly (which I don't recommend), then please compare the content of the files with the output of "crontab -l".

另外,你如何编辑你的cronjobs?使用“crontab -e”或直接编辑文件?如果直接编辑文件(我不推荐),请将文件内容与“crontab -l”的输出进行比较。


推荐阅读
author-avatar
张骞在这里
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有