php Magento 1.9.1 Cron 未运行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29748272/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Magento 1.9.1 Cron Not Running
提问by Vinnie
I am having big issues with the cron of Magento 1.9.1 hoping someone can help. I have AOE installed and see not heartbeat.
我在 Magento 1.9.1 的 cron 上遇到了大问题,希望有人能提供帮助。我安装了AOE,看不到心跳。
I have added my cron job
我已经添加了我的 cron 工作
*/5 * * * * /bin/sh /var/sites/p/domain/public_html/cron.sh
But this still does not run, so I decided to try and try and run cron.php, this does nothing. This is my cron for this
但这仍然没有运行,所以我决定尝试运行cron.php,这没有任何作用。这是我的 cron
*/5 * * * */usr/bin/wget -O /dev/null -o /dev/null http://www.domain.com/cron.php
Based on Magneto 1.8 cron.php I added the following to the cron.php.
基于 Magneto 1.8 cron.php,我在 cron.php 中添加了以下内容。
$isShellDisabled = true;
Based on this still not working I tried the cron.php in the browser. I get an error in the browser that Printing is disabled by default for security reasons.
基于此仍然无法正常工作,我在浏览器中尝试了 cron.php。我在浏览器中收到错误消息,出于安全原因,默认情况下禁用打印。
So I changed my php.ini to memory_limit = 512M just incase. This is still not working.
所以我将我的 php.ini 更改为 memory_limit = 512M 以防万一。这仍然不起作用。
The error I get in my reports for this is:
我在报告中得到的错误是:
a:5:{i:0;s:59:"Mage registry key "_singleton/cron/observer" already exists";i:1;s:537:"#0 /var/sites/p/domain.co.uk/public_html/app/Mage.php(223): Mage::throwException('Mage registry k...')
#1 /var/sites/p/domain.co.uk/public_html/app/Mage.php(477): Mage::register('_singleton/cron...', false)
#2 /var/sites/p/domain.co.uk/public_html/app/code/core/Mage/Core/Model/App.php(1316): Mage::getSingleton('cron/observer')
#3 /var/sites/p/domain.co.uk/public_html/app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('default', Array)
#4 /var/sites/p/domain.co.uk/public_html/cron.php(74): Mage::dispatchEvent('default')
#5 {main}";s:3:"url";s:9:"/cron.php";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:5:"admin";}
Any help would be really great.
任何帮助都会很棒。
Note ** I have change the domain name to DOMAIN due to my site not being suitable for work.
注意** 由于我的网站不适合工作,我已将域名更改为 DOMAIN。
回答by ToxaBes
Few simple steps to fix Magento cron issue:
修复 Magento cron 问题的几个简单步骤:
Go to System > Configuration > Advanced > System > Cron (Scheduled Tasks) and set next values:
- Generate Schedules Every: 15
- Schedule Ahead for: 20
- Missed if Not Run Within: 15
- History Cleanup Every: 10
- Success History Lifetime: 60
- Failure History Lifetime: 600
Clear Cache in System > Cache Management
Clear 'cron_schedule' table. You can do it via phpmyadmin or execute next command in SQL console:
TRUNCATE TABLE cron_schedule;
Add next line to cron settings (use absolute paths):
*/5 * * * * /usr/bin/php /absolute/path/on/your/server/to/file/cron.php
转到系统 > 配置 > 高级 > 系统 > Cron(计划任务)并设置下一个值:
- 生成计划间隔:15
- 提前安排:20
- 如果不在范围内则错过:15
- 历史清理间隔:10
- 成功历史终身:60
- 故障历史寿命:600
在系统 > 缓存管理中清除缓存
清除“cron_schedule”表。您可以通过 phpmyadmin 或在 SQL 控制台中执行下一个命令:
截断表 cron_schedule;
将下一行添加到 cron 设置(使用绝对路径):
*/5 * * * * /usr/bin/php /absolute/path/on/your/server/to/file/cron.php
Note: in some configurations on webserver (apache/nginx) allowed to execute php scripts. In this case add this line to webserver's user crontab. Example for apache: crontab -u apache -e
注意:在网络服务器(apache/nginx)上的某些配置中允许执行 php 脚本。在这种情况下,将此行添加到网络服务器的用户 crontab。apache 示例:crontab -u apache -e
Restart cron daemon.
Check table 'cron_schedule', if it's not empty - Magento cron script start working.
重新启动 cron 守护进程。
检查表'cron_schedule',如果它不为空 - Magento cron 脚本开始工作。
回答by Deus777
Well I've had a different issue. My cron was simply not working, although cron.php was executed properly. Still no output, and no jobs done.
好吧,我遇到了一个不同的问题。尽管 cron.php 已正确执行,但我的 cron 根本无法运行。仍然没有输出,也没有完成任何工作。
I've checked cron_schedule and noticed that last job there is from 19th of March this year (sic!). So i kept on looking for cause.
我检查了 cron_schedule 并注意到上一份工作是从今年 3 月 19 日开始的(原文如此!)。所以我一直在寻找原因。
Finally I've noticed that that there is process running with my cronjob from 19th of March (sic!).
最后,我注意到从 3 月 19 日开始,我的 cronjob 有进程在运行(原文如此!)。
josh 21350 99.6 0.4 350400 133492 ? R Mar19 241812:21 /usr/bin/php /var/www/mysite/cron.php -mdefault
josh 21350 99.6 0.4 350400 133492 ? R Mar19 241812:21 /usr/bin/php /var/www/mysite/cron.php -mdefault
I've killed the job with: kill -9 21350
我用以下方法杀死了这份工作: kill -9 21350
And voila! Suddenly newsletter is being sent!
瞧!突然间通讯正在发送!
I had no idea why, and how this happened. Now i know i should pay attention to it, so I will.
我不知道为什么,以及这是如何发生的。现在我知道我应该注意它,所以我会。
回答by Maur
I just saw that you are using magento 1.9.1.
我刚刚看到您使用的是 magento 1.9.1。
Run the cron using php instead : /usr/local/bin/php -f /home/cpanel_username/public_html/cron.php
使用 php 运行 cron:/usr/local/bin/php -f /home/cpanel_username/public_html/cron.php
This should resolve http permission problems you might be having when using 'usr/bin/wget -O /dev/null -o /dev/null'
这应该可以解决您在使用 'usr/bin/wget -O /dev/null -o /dev/null' 时可能遇到的 http 权限问题
Try that command and let me know if it works for you.
试试那个命令,让我知道它是否适合你。