Code Igniter CLI 与 crontab 条目
当我通过 CLI 启动 CodeIgniter 控制器时,如下所示:
php index.php mycontroller method
一切正常(假设您位于代码点火器文件夹内的正确路径上)
但是,当从 crontab 条目调用同一行时,将执行默认控制器(如如果询问以下行)
php index.php welcome
我尝试为我的 cron 需求创建一个引导程序,并对这个主题进行了广泛的研究,但无济于事。 尝试的解决方案之一: http:// www.asim.pk/2009/05/14/creating-and-installing-crontabs-using-codeigniter/
代码点火器版本:Reactor 2.0.2
执行你知道为什么 Code Igniter 在 CLI 模式与 crontab 下的反应不同吗?旧版本的 CI 似乎运行良好
When I launch a CodeIgniter controller via CLI, like so:
php index.php mycontroller method
everything works well (assume you are on the right paths, inside the code igniter folder)
However, when the same line is invoked from a crontab entry, the default controller is executed (as if the below line was asked)
php index.php welcome
I've attempted to create a bootstrap for my cron needs and done extensive research into this topic, to no avail.
One of the solutions attempted: http://www.asim.pk/2009/05/14/creating-and-installing-crontabs-using-codeigniter/
Code Igniter version: Reactor 2.0.2
Do you know why Code Igniter would react differently in CLI mode vs crontab? Olde versions of CI seems to operate well
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当正常工作的东西在从 crontab 调用时不起作用时,这几乎总是路径问题。
使用 /usr/local/bin/php 而不仅仅是 php 将使其正常工作。对于 php 脚本内的系统调用(例如 passthru、system、exec 等)也是如此。
您可以使用 whereis 命令通过运行以下命令来查找要运行的可执行文件的绝对路径:
When something that normally works, does not work when called from crontab it is nearly always a path issue.
Using /usr/local/bin/php instead of just php will make it work. The same is true for system calls inside the php script e.g. passthru, system, exec etc.
You can use the whereis command to find the absolute path to the executable you want to run by running e.g.: