简体   繁体   English

Magento-cron作业脚本正在运行,但未发送Magento订单确认电子邮件

[英]Magento - cron job script is running, but Magento order confirmation emails are not sending

As the Magento documentation states, you need to set up a cron job on your web server in order to get things like order confirmation emails to send out, like so: Magento文档所述,您需要在Web服务器上设置cron作业,以便发送诸如订单确认电子邮件之类的信息,如下所示:

* * * * * /bin/sh /absolute/path/to/magento/cron.sh

This is a very simple cron job. 这是一个非常简单的cron工作。 The issue is, automated tasks are not completing in Magento. 问题是,Magento中的自动化任务未完成。 It's as if the script isn't being run by the cron job. 好像脚本不是由cron作业运行的。 And as a result, order confirmation emails are not sending (among all the other Magento automated tasks). 结果,订单确认电子邮件没有发送(在所有其他Magento自动任务中)。

I've installed the AOE Scheduler extension to double-check every automated task in Magento and see when tasks are completing (or, in this case, when they're not). 我已经安装了AOE Scheduler扩展,以仔细检查Magento中的每个自动化任务,并查看任务何时完成(或者在这种情况下还没有完成)。 None of the tasks including core_email_queue_send_all are completing on the 1-minute-interval basis. 包括core_email_queue_send_all在内的所有任务都不会以1分钟为间隔完成。

Now here's the weird part. 现在这是奇怪的部分。 If I just go run the cron.php script ( cron.sh triggers cron.php ) by loading it up in my web browser at mydomain.com/cron.php , the Magento automated tasks all execute! 如果我只是通过将其加载到我的Web浏览器mydomain.com/cron.php运行cron.php脚本( cron.sh触发cron.php ),则将执行Magento自动化任务! And since the script works like this when I run it manually, and I know cron jobs are working...I can't figure this out! 而且由于脚本在我手动运行时是这样的,而且我知道cron作业正在运行...我无法弄清楚!

Please help! 请帮忙!

ADDITIONAL DETAILS 额外细节

Here's how I know cron jobs are working—I have tested cron jobs on my server by creating a PHP script that sends a basic email with mail() , and ran a similar cron job to the one above to execute it every minute—the cron job functions normally. 这就是我知道cron作业正在工作的方式-我已经通过创建一个PHP脚本在我的服务器上测试了cron作业,该脚本发送了具有mail()的基本电子邮件,并运行了与上述类似的cron作业,每分钟执行一次-cron工作正常。 I am also getting MAILTO emails from the server every time the cron job runs. 每当cron作业运行时,我也会从服务器收到MAILTO电子邮件。 No errors that I can see. 我看不到任何错误。

I can also execute this exact command in the cron job... 我也可以在cron作业中执行这个确切的命令...

/bin/sh /absolute/path/to/magento/cron.sh

...in Terminal when I SSH in, and it runs the script successfully and Magento runs all automated tasks. ...在SSH中进入终端时,它成功运行了脚本,Magento运行了所有自动化任务。 It just doesn't run every minute in the cron job! 它只是不会在cron作业中每分钟运行一次!

This is totally weird and I can't figure it out.... At the end of the day, all this work I did on this Magento store is moot if customer's can't check out and get confirmation emails. 真是太奇怪了,我无法解决...。总而言之,如果客户无法退房并收到确认电子邮件,那么我在这家Magento商店所做的所有工作都没有意义。

Any advice would be extremely appreciated. 任何建议将不胜感激。

UPDATE UPDATE

I was able to get by with using a wget command to call cron.php , but this still doesn't feel like a permanent solution. 我可以通过使用wget命令调用cron.phpcron.php ,但这仍然不是永久解决方案。

wget -O /dev/null -q http://domain.com/cron.php

While it's technically working now, Magento's documentation specifically recommends running cron.sh , not cron.php . 尽管从技术上来说现在已经可以使用,但是Magento的文档特别建议运行cron.sh而不是cron.php Still would love a concrete answer to why the cron job won't run cron.sh with sh . 对于为什么cron作业无法与sh一起运行cron.sh问题,仍然会喜欢一个具体的答案。

Some steps I would be trying: 我会尝试的一些步骤:

In terminal: 在终端:

Check your cron log: 检查您的cron日志:

tail -f /var/log/cron

Can you see the commands being run? 您可以看到正在运行的命令吗?

Check if cronjobs are present: 检查是否存在cronjobs:

crontab -l

Check if the cron user has executable permissions for the file, if not: 检查cron用户是否对该文件具有可执行权限,否则:

chmod +x file.sh

Is cron running? cron在运行吗? check to see if a process is running: 检查进程是否正在运行:

pgrep crond

In case of errors you will get an email with the error recorded, but this needs configuration first. 如果发生错误,您将收到一封记录了错误的电子邮件,但这需要首先进行配置。 You can see the solution here https://www.phase2technology.com/blog/how-to-enable-local-smtp-server-postfix-on-os-x-leopard/ 您可以在这里查看解决方案https://www.phase2technology.com/blog/how-to-enable-local-smtp-server-postfix-on-os-x-leopard/

In this case this solution here helped me http://support.xtento.com/wiki/Setting_up_the_Magento_cronjob 在这种情况下,这里的解决方案可以帮助我http://support.xtento.com/wiki/Setting_up_the_Magento_cronjob

My environment is OSX El Capitain with local mail postfix enabled to send cron status emails on a gmail account I set for testing orders in my Magento shop, MAMP for testing Magento locally and AOE Scheduler Magento extension installed and configured. 我的环境是OSX El Capitain,启用了本地邮件后缀,可以在我为在Magento商店中测试订单设置的gmail帐户上发送cron状态电子邮件,为在本地测试Magento设置的MAMP以及已安装和配置的AOE Scheduler Magento扩展程序。

The code that worked for me is: 对我有用的代码是:

MAILTO="somebody@test.com"

curl -s -o /dev/null http://www.YOURDOMAIN.com/PATH_TO_MAGENTO/cron.php /dev/null

I hope this helps someone as I lost almost 2 days getting the right settings. 我希望这对某人有所帮助,因为我失去了将近2天的时间才能获得正确的设置。 Good luck! 祝好运!

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

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