我有一个用 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/