简体   繁体   中英

CodeIgniter CRON job

I'm trying to set up a CRON job to make some database changes on a CodeIgniter install and having issues with the host that are stopping it from working. The host's CRON setup only allows you to execute a PHP file rather than calling a URL.

What I've tried:

Curl, wget, file_get_contents, fopen, http_get from a static PHP file - all not allowed by the host

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

After unfruitful conversations with the host I'm out of ideas. Does anyone know how I could call a controller method from a static PHP file without the above?

First of all, I'm assuming you are using CI ver 2> (CLI support was not available before).

Secondly, lets say that the page you are trying to fire under cron is http://www.mysite.com/index.php/cronjobs/thejob

The correct command would be:

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

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

You need to have php compiled with command line support. You can verify this by:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM