如何在cakephp中运行cron job

时间:2015-10-12 11:58:50

标签: cakephp cron

我正在尝试使用cakephp中的cron job从数据库中删除数据。我在/app/Console/Command/TestShell.php创建了一个TestShell.php文件,其中包含以下代码:

<?php
class TestShell extends AppShell {

    public $uses = array('BillsReceivable'); 

    public function main() {
        $this->BillsReceivable->deleteAll(array(
          'BillsReceivable.days >='=>30, 
        ));
        $this->out('Records deleted..');
    }
}

我的cron命令是:

/home/bigzip/public_html/TimeZip/app/Console/cake -app /home/bigzip/public_html/TimeZip/app TestShell

但它不起作用。请帮助。

2 个答案:

答案 0 :(得分:1)

cd /home/bigzip/public_html/TimeZip/app/
sudo Console/cake test

答案 1 :(得分:0)

cakephp cron job

cd / full / path / to / app&amp;&amp;控制台/蛋糕myshell myparam
-working定义工作目录

/home/bigzip/public_html/TimeZip/app/Console/cake.php -app /home/bigzip/public_html/TimeZip/app -working /home/bigzip/public_html/TimeZip/app TestShell
上面的代码可以帮助你

相关问题