我有一个 cron 作业需要在我的网站上运行。我已经设置了模型和 Controller ,然后将以下 cron 作业设置为每小时运行一次:
/usr/bin/php /path/to/directory/index.php cron resetViews;
我的 config.php 文件中 $config 的 URI_PROTOCOL 索引设置为 AUTO,并且没有拼写错误。
当我运行命令时,我得到了我主页的 4 html,这也是我的默认 Controller 。有什么想法吗?
编辑
我已将命令更改为:
cd /path/to/directory; /usr/bin/php index.php cron resetViews;
现在我在主页的打印输出顶部收到以下错误:
PHP: Error parsing /home/crowston/public_html/2012/php.ini on line 1
这是我的整个 php.ini 文件:
error_reporting(E_ALL);
ini_set('display_errors', 'On');
我也尝试过使用空白的 php.ini fie 无济于事。
php.ini 文件在整个站点构建过程中没有引起任何错误:S
最佳答案
你可以试试这个:
wget http://localhost/index.php/cron/resetViews
基本上,既然你有能力使用肯定会调用 Controller 方法的 wget,为什么还要使用 cli?
编辑:
引用this ,也许您应该对该目录执行 cd
命令,然后调用 index.php。值得一试,因为如果 ci 试图从相对于 cron 密码的路径加载 Controller ,那么它可能会抛出 404。对吗?
关于linux - Codeigniter cron 作业问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11793479/