简体   繁体   中英

Codeigniter cron job issue

I have a cron job which needs running on my site. I have set up the model and controller, then set the following cron job to run every hour:

/usr/bin/php /path/to/directory/index.php cron resetViews;

I have the URI_PROTOCOL index of $config in my config.php file is set to AUTO and there are no spelling errors.

When I run the command, I get the4 html of my home page, which is also my default controller. Any ideas?

Edit

I have changed the command to:

cd /path/to/directory; /usr/bin/php index.php cron resetViews;

and now I get the following error on top of a printout of my home page:

PHP: Error parsing /home/crowston/public_html/2012/php.ini on line 1

Here is my entire php.ini file:

error_reporting(E_ALL);
ini_set('display_errors', 'On');

I have also tried with a blank php.ini fie to no avail.

The php.ini file has caused no errors throughout the entire construction of the site :S

You can try this:

wget http://localhost/index.php/cron/resetViews

Basically, since you have the capability to use wget that will definitely call the controller method, why use cli?

EDIT:

referring to this , perhaps you should do a cd command to the directory and then call index.php. Worth a try because if ci was trying to load controller from path relative to the cron's pwd, then it might throw a 404. right?

It works fine for me :

wget -O /dev/null -q http://www.mani.com/project-name/index.php/tools/sendPushNotification

(-O /dev/null -q) Command is used to remove log file

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