我几乎成功地在我的服务器上设置了Cron作业,但我无法调用正确的控制器。CLI(命令行界面)Cron作业没有得到正确的控制器
当我只在语句成功运行脚本时从我的浏览器中删除了CLI时。
// Make sure the request is being made by a CRON Job
if (! $this->input->is_cli_request()) exit('Only CLI access allowed');
我正在通过Cron守护进程通过电子邮件发送输出。我试过这个命令,下面是我的结果。
工作:
/usr/bin/php /home/dlp/public_html/abc.org/index.php birthday
结果:
我得到默认控制器index.php
的第一个电子邮件HTML输出和birthdady
控制器的第二个电子邮件输出的2个电子邮件。
我的控制器的代码是。
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Birthday extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load->database();
$this->load->library('email');
}
/**** function for sending news letter on birthday ****/
function index()
{
error_log("birthday function call",1,"[email protected]");
exit;
}
}
?>
我不知道我在做什么错。
在此先感谢您的帮助。
您使用$ _ SERVER某处你的CLI脚本?可以张贴部分脚本,这会更有帮助 –
我发布了控制器的代码。 – Haseeb
也许你可以在cron中使用wget(http:// whatever_you_used_on_browser)而不是/ usr/bin/php调用。你可能遇到的唯一问题是如何限制呼叫者到cron –