Search code examples
phpcodeignitercroncron-task

How to pass parameter from cron command to codeigniter function?


I am working with code-igniter and running a function from cron job.

class event extends CI_Controller {
  public function newEvent()
    {
         //some process here using the parameter
    }

} 

cron command:

* */2 * * * /usr/bin/php /var/www/project/index.php 'event/newEvent/parameter'

I want to pass the parameter like written in cron command and do some process with that parameter in newEvent function.

What extra code I should write in my function to receive the parameter from cron command.

Thanks


Solution

  • I have tried this and it's working for me.

    * */2 * * * /usr/bin/curl http://domain.com/index.php/event/newEvent/parameter