cron作业返回登录页面html在codeigniter中 [英] cron job return login page html in codeigniter
问题描述
在我的应用程序中,我需要为日常更新设置cron作业。我正在使用CodeIgniter 3.0
In my application i need to set cron job for daily updation. I am using CodeIgniter 3.0
我的config.php文件
My config.php file
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
这是我的控制人
class Cron extends CI_Controller {
public function cron_job(){
if (!$this->input->is_cli_request()){
echo 'test';
//show_error('Direct access is not allowed');
}
else{
echo 'call';
}
}
}
在cpenal中设置了路径,例如
and i have set path in cpenal like
/usr/bin/php /home/public_html/my_app/index.php cron cron_job
但这返回登录页面的html,它也是应用程序的首页。
我认为路径存在问题,那么我该如何解决?
But this return html of login page which is also front page of app. I think there is issue with path, So how can i fix it?
推荐答案
我发现两者之间有两个主要区别您的代码和我正在工作的CI3 cronjobs。
I see two main differences between your code and my working CI3 cronjobs.
首先是我使用 if(is_cli())
而不是 if(!$ this-> input-> is_cli_request()){
。
First is I use if (is_cli())
instead of if (!$this->input->is_cli_request()){
.
第二,可能取决于您的服务器设置,但尝试在 / usr / bin / php 之后添加 -cli 就像我在这里一样:
Second, and may depend on your server settings but try adding -cli after /usr/bin/php as I have here:
/usr/bin/php-cli /home/public_html/index.php cron cron_job
请告诉我是否有帮助
这篇关于cron作业返回登录页面html在codeigniter中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!