See the below video and follow the steps one by one
Step 1
//Write code in controller file
<?php
class cron_job_cnt extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->helper(array('form', 'url'));
$this->load->library("pagination");
}
function cron_job()
{
$this->load->model('cron_job_model');
$this->cron_job_model->cron_job();
}
}
?>
Step 2
//Write code in model file
<?php
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Credentials: true");
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token , Authorization');
class cron_job_model extends CI_Model
{
function cron_job()
{
$msg = "Hi! Thanks for watching this video. Comments if you want this code.";
$msg = wordwrap($msg,70);
// send email
mail("[email protected]","Codeignator cron job by Shinerweb",$msg);
}
}
?>
Step 3
/usr/local/bin/php /home/fbi1glfa0j7p/public_html/cakenbake.in/index.php cron_job_cnt/cron_job
Don’t forgot to give space after index.php
/home/fbi1glfa0j7p/public_html/cakenbake.in/index.php : This is your Home Directory and live website address
cron_job_cnt/cron_job : Controller name and function name