【问题标题】:CakePHP Shell cronjob: Error: Class TestingShell could not be loadedCakePHP Shell cronjob:错误:无法加载类 TestingShell
【发布时间】:2011-04-28 08:05:10
【问题描述】:

我正在尝试在 CakePHP 工作中获得一个 cronjob。但我收到此错误:Error: Class TestingShell could not be loaded.

这是我的/app/vendors/shells/testing.php 文件:

class TestingShell extends Shell    {
var $uses = array('Test');
function main(){
    $this->out('Number of tests :');
    $this->out($this->Test->find('count'));
    $this->out('.');
    if($this->Test->delete(1)){
        $this->out('test deleted'); 
    }
    else{
        $this->out('test not deleted'); 
    }
}

}

我这样调用 cronjob:/home/root/public_html/site/cake/console/cake -app /home/root/public_html/site/app testing

我做错了什么?非常感谢!

编辑我必须补充一点,在本地,shell 工作正常。

【问题讨论】:

    标签: cakephp cron


    【解决方案1】:

    查看这个错误报告——这是我的问题。

    http://cakephp.lighthouseapp.com/projects/42648/tickets/1601-cakephp-138-console-ignores-app-parameter

    回滚到 1.3.7 是快速修复。

    【讨论】:

    • 你是金子!非常感谢!现在它起作用了!但是,它仍然给我一个错误,TERM environment variable not set.,但它完成了它的工作。为什么会抛出这个错误?还有,为什么 1.3.8 版本不工作?如何解决?将来我是否能够对 Cake 进行更新,或者我是否会在 cronjob 不工作的情况下再次面临这种奇怪的行为?
    • 我相信他们已经在开发分支中修复了它。我希望 1.3.9 可以正常工作。 TERM 环境的事情是不相关的。
    【解决方案2】:

    看看这个,你可能还需要添加的shell脚本

    http://book.cakephp.org/view/1110/Running-Shells-as-cronjobs

    你也有错误的参数,它的

    1 * * * * cake/path scritp params -app app/path

    【讨论】:

    • 我没有遵循该教程。我对此进行了指导:stackoverflow.com/questions/3192070/cron-job-with-cakephp。无论如何,我已经尝试过这个/home/root/public_html/site/cake/console/cake testing -app /home/root/public_html/site/app,但它仍然不起作用......同样的错误。我对所有 cronjob/Linux/命令行的东西都是一个新手,所以我真的不明白出了什么问题。但是由于它给了我这个错误,我相信脚本发现它应该是某个地方的 TestingShell 类(基于我编写的testing 命令),但它找不到它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-31
    • 2013-07-24
    • 2017-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多