php - Codeigniter 类 cron 不起作用

标签 php linux codeigniter cron

我有一个用 codeigniter 开发的站点,我想在其中使用 cron Controller 。 我写了这个 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();
    }
}

函数 importFromXml 工作正常,因为如果我从其他 Controller 调用它没有问题。

在/etc/crontab 中我的 Linux 服务器中,我添加了这一行以每 10 分钟调用一次此函数:

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

但是我没有看到任何变化,比如函数没有被调用。

我错了吗?

最佳答案

cron 入口应该是这样的

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

关于php - Codeigniter 类 cron 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17399740/

相关文章:

php - 电子邮件表格问题

php - 为什么当 'display_errors' 打开时此语法错误会返回 HTTP 错误 500?

mysql - UDF结果错误

php - CodeIgniter 不断为 int 值插入 2147483647

php - Codeigniter 中的内连接查询

php - 使用 uri 段获取值

php - 显示数据库中的元素

php - Laravel 社交名媛 : InvalidStateException (sometimes)

linux - 如何在 bash 脚本和 Matlab 之间传递变量

linux - RHEL3 上的 GTKMM?