Blog of King Software

Learn online with us in simple steps.

RUNNING CRON JOB FOR CODEIGNITER

Created by Bhavesh Gohil on Date: 16/12/2020

Addition of cron jobs in CodeIgniter application can provide additional usefullness. In this blog, You can see that how to run cron job in Codeigniter

STEPS TO CREATE CRON JOB FOR CODEIGNITER

Step 1:   Create a simple controller:

<?php
class Demo_cron_ci extends CI_Controller{
public function__construct() {
parent::__ construct();

}
function demo_cron()
{
This code for demo purpose, you can replace it with your code.
$this->load->model('demo_cron_model');
$this-> demo_cron_model-> demo_cron();
}
}
?>

Step 2:   Use this command for running cron job file:

  • php /home/username/index.php /CONTROLLERNAME/METHODNAME
  • Exammple:/user/local/bin/php/home/username/public_html/index.php demo_cron_ci/demo_cron
  • don't forgot to give space after index.php
  • demo_cron_ci/demo_cron: Controller name and function name