简体   繁体   English

Codeigniter Cron工作问题

[英]Codeigniter cron job issue

I have a cron job which needs running on my site. 我有一项Cron工作,需要在我的网站上运行。 I have set up the model and controller, then set the following cron job to run every hour: 我已经设置了模型和控制器,然后将以下cron作业设置为每小时运行一次:

/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. 我在config.php文件中将$ config的URI_PROTOCOL索引设置为AUTO,并且没有拼写错误。

When I run the command, I get the4 html of my home page, which is also my default controller. 当我运行命令时,我得到了主页的HTML4,这也是我的默认控制器。 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 PHP:在第1行上解析/home/crowston/public_html/2012/php.ini时出错

Here is my entire php.ini file: 这是我的整个php.ini文件:

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

I have also tried with a blank php.ini fie to no avail. 我也尝试了用空白的php.ini国际剑联无济于事。

The php.ini file has caused no errors throughout the entire construction of the site :S php.ini文件在站点的整个构建过程中未引起任何错误: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? 基本上,既然您具有使用肯定会调用controller方法的wget的功能,那么为什么要使用cli?

EDIT: 编辑:

referring to this , perhaps you should do a cd command to the directory and then call index.php. 参照 ,也许您应该对目录执行cd命令,然后调用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? 值得一试,因为如果ci试图从相对于cron的pwd的路径加载控制器,那么它可能会抛出404。

It works fine for me : 这对我来说可以 :

wget -O /dev/null -q http://www.mani.com/project-name/index.php/tools/sendPushNotification 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 (-O / dev / null -q)命令用于删除日志文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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