这是我的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
发布评论