Codeigniter cron作业问题


Codeigniter cron job issue

我有一个cron作业,需要在我的站点上运行。我已经设置了模型和控制器,然后将以下cron作业设置为每小时运行一次:

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

我的config.php文件中的$config的URI_PROTOCOL索引设置为AUTO,并且没有拼写错误。

当我运行该命令时,我会得到主页的4html,这也是我的默认控制器。有什么想法吗?

编辑

我已将命令更改为:

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

现在我在主页的打印输出上出现了以下错误:

PHP:解析第1行上的/home/crowston/public_html/2012/PHP.ini时出错

这是我的整个php.ini文件:

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

我也尝试过使用空白的php.ini fie,但没有成功。

php.ini文件在整个站点构建过程中没有造成任何错误:S

你可以试试这个:

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

基本上,既然你有能力使用wget,它肯定会调用控制器方法,为什么要使用cli?

编辑:

提到这一点,也许你应该对目录执行cd命令,然后调用index.php。值得一试,因为如果ci试图从相对于cron的pwd的路径加载控制器,那么它可能会抛出404。正确的

它对我来说很好:

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

(-O/dev/null-q)命令用于删除日志文件