[英]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.
# /etc/init.d/crond
and start it again # /etc/init.d/crond start,
# /etc/init.d/crond
并重新启动它# /etc/init.d/crond start,
Please check this similar So thread by erotsppa请通过erotsppa检查这个类似的So 线程
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.