cron job return login page html in codeigniter

一世执手 提交于 2019-12-23 03:31:49

问题


In my application i need to set cron job for daily updation. I am using CodeIgniter 3.0

My config.php file

$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

Here is my controller

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';
    }

    }
}

and i have set path in cpenal like

/usr/bin/php /home/public_html/my_app/index.php cron cron_job

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?


回答1:


I see two main differences between your code and my working CI3 cronjobs.

First is I use if (is_cli()) instead of if (!$this->input->is_cli_request()){.

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

Please let me know if this helps



来源:https://stackoverflow.com/questions/38051672/cron-job-return-login-page-html-in-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!