简体   繁体   English

Codeigniter类的cron不起作用

[英]Codeigniter class cron doesn't work

I have a site developed in codeigniter where I want to use a cron controller. 我有一个在Codeigniter中开发的网站,我想使用cron控制器。 I have write this controller: 我写了这个控制器:

class Cron extends CI_Controller {

    function __construct()
    {
        parent::__construct();

        // this controller can only be called from the command line
        if (!$this->input->is_cli_request()) show_error('Direct access is not allowed');
    }

    function importMeteo()
    {
        $this->load->model('Meteo_model');
        $this->Meteo_model->importFromXml();
    }
}

The function importFromXml works fine because if I call it from other controller no problems. 函数importFromXml可以正常工作,因为如果从其他控制器调用它,则不会出现问题。

Into my linux server in /etc/crontab I have added this line to call this functuon every 10 minutes: 在/ etc / crontab中的linux服务器中,我添加了以下行,每10分钟调用一次此functuon:

*/10 * * *      root    php /var/www/public/my_site.com/index.php cron/importMeteo

But I don't see any change like the function isn't called. 但是我看不到没有调用该函数的任何变化。

I'm wrong something? 我错了吗?

cron条目应该是这样的

*/10 * * * * php /var/www/public/my_site.com/index.php cron importMeteo

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

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