我正在尝试创建一个 CRON 作业,该作业指向我构建的 Code Igniter 系统中文件内的一个函数。我已经在我的 CPanel 上创建了 CRON 作业,并且我已经使用根文件中的一个简单的邮件 php 函数对其进行了测试,并且它可以正常工作,但是,我希望将 CRON 作业指向我的 MVC 框架中的一个位置,并且对于一些原因这似乎不起作用。
这是在我的 CPanel 上设置的 CRON 作业:
0 0 * * 1 wget -q -O /dev/null http://www.urlhere.co.uk/index.php/cron_event/send_reminders
这是我希望运行的控制器。它的位置在 system/controllers/cron_event.php 中:
<?php
class Cron extends Controller {
function Cron_event()
{
parent::Controller();
}
/**
* The index method just displays an access denied message, as we don't support viewing this module in the browser.
*/
function index()
{
$this->send_reminders();
$this->load->view('themes/base/header', array('title'=>"Access Denied"));
$this->load->view('cron/access_denied');
$this->load->view('themes/base/footer');
}
/**
* Updates the PR Online Calendar by sending out email notifications for events that have not yet had them sent out.
*/
public function send_reminders() {
$to = 'jamesholman@urlgoeshere.co.uk';
$from = 'bigwavetest';
$message = 'test';
mail($to, $from, $message);
}
}
?>
当我指向这个控制器时,CRON 作业停止工作。
我有一种感觉,因为我没有包含和需要 Code Igniter 框架文件,但我不确定。有人对为什么这不起作用有任何想法吗?
提前致谢!