How to create cron job in codeigniter | cron job in codeigniter | auto schedule mail | Shinerweb

See the below video and follow the steps one by one

Step 1

//Write code in controller file
class cron_job_cnt extends CI_Controller { 
    public function __construct() {
			$this->load->helper(array('form', 'url'));
    function cron_job()

Step 2

//Write code in model file
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/ cron_job_cnt/cron_job

Don’t forgot to give space after index.php

/home/fbi1glfa0j7p/public_html/  : This is your  Home Directory and live website address
cron_job_cnt/cron_job : Controller name and function name

Related Posts

Divyesh Patel

I'm Divyesh Patel, Web & App developer. I want to make things that make a difference. With every line of code, i strive to make the web a beautiful place.

Leave a Reply

Your email address will not be published.