Kohana 3 和 CRON 总是访问index.php(不遵循 URI 参数)
好的,我希望这是我关于 CRON 作业和 Kohana 3 的最后一个问题。注意:其他问题不是重复的,只是其他问题。
这是我的 CRON 作业(在 cPanel 中设置)
php /home/user/public_html/index.php --uri=properties/update
按照
我已经设置好了,所以它会通过电子邮件将输出发送给我。每 5 分钟运行一次。
不幸的是,它总是通过电子邮件向我发送我网站主页的源代码(index.php 或 /)。
我可以在浏览器中正常访问该 URL,即 http://www.example.com/properties/update
并且它可以正常工作并完成其工作。我可以告诉 Cron 永远不会点击脚本,因为我有一个 文件记录器就位。
这与 .htaccess 有什么关系吗?
以前有人遇到过这种情况吗?他们是如何解决的?
非常感谢。
更新
如果有人感兴趣的话,这是我在 bootstrap.php
中的主页路线。
Route::set('home', '')
->defaults(array(
'controller' => 'home',
'action' => 'index'
));
这是定义的第一条路线。
另一个更新
同样奇怪的是,从 CRON 发送电子邮件时 var_dump(Kohana::$is_cli);
会生成 false
。
OK, I hope this is my last question about CRON jobs and Kohana 3. Note: others are not duplicates, just other problems.
Here is my CRON job (setup in cPanel)
php /home/user/public_html/index.php --uri=properties/update
As per this answer.
I have set it up so it emails me the output. It is running every 5 mins.
Unfortunately, it always emails me the source of the home page of my site (index.php or /).
I can access that URL fine in my browser, i.e. http://www.example.com/properties/update
and it works and does its job correctly. I can tell the Cron is never hitting the script because I have a file logger in place.
Would this have anything to do with .htaccess?
Has this happened to anyone before, and how did they fix it?
Many thanks.
Update
Here is my home route in bootstrap.php
if anyone is interested.
Route::set('home', '')
->defaults(array(
'controller' => 'home',
'action' => 'index'
));
It is the first route defined.
Another Update
What's weird too, is that a var_dump(Kohana::$is_cli);
produces false
when emailed from the CRON.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
万一其他人遇到这个问题,在花了几个小时试图解决这个问题之后,我最终发现
我不得不使用
php 的确切路径,而不是使用(使用你的示例),但是如果不使用这个,它就没有使用 CLI,虽然我不完全确定,但我认为它正在卷曲它。
我还发现,在调用这些操作时,我也必须明确声明索引操作;它们没有作为控制器的默认操作被调用(尽管奇怪的是, before()被调用)。
In case anyone else has this problem, after spending hours trying to work it out, I eventually discovered that instead of using (to use your example)
I had to use
The exact path to php may vary, but without using this, it wasn't using CLI, and although I'm not entirely sure, I think it was CURLing it.
I also found that I had to explicitly state the index actions too, when calling those; they weren't called as the controllers' default actions (although oddly, before() was called).
将您的路线更新为:
或:
Update your route to:
or: