简体   繁体   English

Docker alpine linux cron作业每次运行3次

[英]Docker alpine linux cron jobs running 3 times every time

I'm running crontab-ui and php inside a docker container deployed to azure.我在部署到 azure 的 docker 容器中运行 crontab-ui 和 php。 Every cron job I set up it runs 3 times (email sent 3 times, logged 3 times).我设置的每个 cron 作业运行 3 次(电子邮件发送 3 次,记录 3 次)。 Tried a different approach on another container and got the same result.在另一个容器上尝试了不同的方法并得到了相同的结果。

Here is my crontab:这是我的 crontab:

*       *       *       *       *       sh /usr/local/bin/triage-rotate.sh
*       *       *       *       *       sh /usr/local/bin/wp-cron.sh

and here is wp-cron.sh这是 wp-cron.sh

#!/bin/sh
ps -ef | grep "wp cron" | grep -v grep
process=`ps -ef | grep "wp cron" | grep -v grep | wc -l`
echo $process
if [ $process -eq 0 ]; then 
    wp cron event run --due-now --path=/var/www/html/ --allow-root
fi

I was watching top on terminal and wp-cron.sh only gets triggered once.我在终端上观看top并且 wp-cron.sh 只被触发一次。 I have a wp scheduled event that sends an email twicedaily and I receive 3 emails every time.我有一个 wp 预定事件,每天两次发送 email,我每次收到 3 封电子邮件。

Any thoughts?有什么想法吗?

This issue may be possible that your hook might be being executed more than once, you can prevent execution of hook more than once on your specific code using did_action.这个问题可能是您的钩子可能被多次执行,您可以使用did_action.

  • Ensure you should set WordPress Cron to "NO if you are utilizing the cron job URL to initiate sending. Otherwise, if multiple people attempt to send at the same time, multiple email will be triggered at the end如果您正在使用 cron作业 URL来发起发送,请确保将 WordPress Cron 设置为“NO”。否则,如果多人同时尝试发送,最后将触发多个 Z0C83F57C786A0B4A39EFAB23731
  • Check whether you accidentally initialized the cron service at twice and try to stop cron # /etc/init.d/crond and start it again # /etc/init.d/crond start,检查是否两次不小心初始化了 cron 服务并尝试停止 cron # /etc/init.d/crond并重新启动它# /etc/init.d/crond start,
  • please check whether your system have two cron daemon.请检查您的系统是否有两个 cron 守护进程。 The fact that two cron daemons are operating simultaneously due to which these issues may occur.两个 cron 守护进程同时运行的事实可能会出现这些问题。 Also, check another user installed and/or activated or needs to be active at once.此外,请检查已安装和/或激活或需要立即激活的其他用户。

Please check this similar So thread by erotsppa请通过erotsppa检查这个类似的So 线程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM