Search code examples
codeigniter

Running a cron job with CodeIgniter


I need to run a cron job on a file using CodeIgniter but CodeIgniter won't let me run a file directly. i.e.

I can run the controller in the browser with:

api.example.com/index.php/cron

My hosting only lets me run PHP files and I can't do it via the command line because it won't let me run wget or curl.

How can I make CodeIgniter run a file like below:

api.example.com/index.php/application/controller/cron.php

I can call that file with my hosting.

Updated

Thought i would just update none of the options worked for me i ended up changing hosting and doing the following.

http://devsforrest.com/116/setup-a-cronjob-to-run-every-5-minute-on-media-temple


Solution

  • Uset wget command along with your url to run cron in codeigniter file in your case it should be:

    wget api.example.com/index.php/controller/function
    

    and be careful do not use path of file use the url which invokes your function.