Hi, i want to test cron job and check it. But i don't know how to use $this->input->is_cli_request(). My controller
PHP Code:
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->helper('url');
$this->load->helper('security');
$this->load->library("session");
$this->load->library('form_validation');
$this->load->helper('date');
$this->load->helper('string');
}
public function index()
{
$dates = "%Y-%m-%d %H:%i:%s"; $time = time();
$this->load->model("msite");
$data_insert = array(
"time" => mdate($dates, $time),
);
$this->msite->insertT($data_insert);
$this->load->view('welcome_message');
}
}
And cron job in my host
PHP Code:
php public_html/test/index.php welcome index >> /dev/null
It can run and add in my database but when i add $this->input->is_cli_request(). It can't run - What can i edit cron job in host?
PHP Code:
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->helper('url');
$this->load->helper('security');
$this->load->library("session");
$this->load->library('form_validation');
$this->load->helper('date');
$this->load->helper('string');
}
public function index()
{
if(!$this->input->is_cli_request())
{
echo "Not run";
return;
}
$dates = "%Y-%m-%d %H:%i:%s"; $time = time();
$this->load->model("msite");
$data_insert = array(
"time" => mdate($dates, $time),
);
$this->msite->insertT($data_insert);
$this->load->view('welcome_message');
}
}