Codeigniter and Cron job

Posted: February 18, 2016 in Codeigniter
Tags:

Here is how to use the cron job with codeigniter, which meaningful for background tasks for your application.

$ crontab -e

Insert this line:
26 01 * * * php /var/www/my_project_folder/index.php cron my_test my_variable > /home/log/my_test.log

*cron is your controller
*my_test is your function in controller
*my_variable is your parameter value
*my_test.log output any results to file

Eg: Controller cron.php

class Cron extends CI_Controller
{
    function my_test($param)
   {
      #run your code/process here
   }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s