CodeIgniter CRON Operation

I'm trying to set up a CRON job to make some changes to the database when installing CodeIgniter and there are problems with the host that prevent it from working. Setting up the CRON host allows you to execute a PHP file rather than invoke a URL.

What I tried:

Curl, wget, file_get_contents, fopen, http_get from a static PHP file - all this is prohibited by the host

/path/to/php /path/to/index.php controller method - use the command line interface

After fruitless conversations with the owner, I have no ideas. Does anyone know how I could call the controller method from a static PHP file without the above?

+4
source share
1 answer

First of all, I assume that you are using CI ver 2> (CLI support was not previously available).

Secondly, let's say that the page you are trying to run in cron is http://www.mysite.com/index.php/cronjobs/thejob

The correct command is:

 /usr/bin/php /var/www/rootCIfolder/index.php cronjobs thejob 

Replace /usr/bin/php location of your /usr/bin/php executable and /var/www/rootCIfolder with the location of your CI folder.

You need to compile php with command line support. You can check this out:

 # php -v PHP 5.3.3 (cli) (built: Jul 3 2012 16:53:21) 
+1
source

All Articles