从cronjob运行时,CodeIgniter is

编程入门 行业动态 更新时间:2024-10-25 08:27:40
本文介绍了从cronjob运行时,CodeIgniter is_cli_request()返回false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是我的cronjob的命令

Here is my cronjob's command

php /home/toolacct/public_html/index.php cronjob fetch_emails

php /home/toolacct/public_html/index.php cronjob fetch_emails

这是我的CodeIgniter cronjob控制器

Here is my CodeIgniter cronjob controller

class Cronjob extends CI_Controller { function __construct() { parent::__construct(); die($this->input->is_cli_request()?'T':'F'); $this->load->model('cronjob_model'); } public function fetch_emails() { $this->cronjob_model->fetch_emails(); } public function index_popularity() { $this->db->query('CALL update_email_data_popularity()'); } }

cronjob会说 F 为什么?

The cronjob says "F" Why?

注意:如果我创建这样的函数

A side note: If I create a function like this

function is_cli_request() { return isset($_SERVER['SHELL']); }

它正确返回true或false,而CodeIgniter总是返回false。

It returns true or false correctly, while CodeIgniter always returns false.

推荐答案

输入类文档说, $ this-> input-> is_cli_request()使用STDIN常量检查其是否在命令上运行

The Input Class Documentation says that $this->input->is_cli_request() uses the STDIN constant to check if its running on the command line.

尝试使用PHP的命令行版本(php-cli),因为在运行标准PHP可执行文件时似乎未设置STDIN常量( php)。

Try using the command line version of PHP instead (php-cli), since the STDIN constant doesn't appear to be set while running the standard PHP executable (php).

更多推荐

从cronjob运行时,CodeIgniter is

本文发布于:2023-07-16 04:10:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1117698.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:cronjob   CodeIgniter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!