我幾乎成功地在我的服務器上設置了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 –