Codeigniter is_cli_request() stops cpanel cron job from working

后端 未结 2 1573
自闭症患者
自闭症患者 2021-01-25 10:34

On my website I use cron job on cpanel.

I have this code below in the construct area of controller but it stops the cpanel cron job from working.

if (!$t         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-25 11:32

    Solved now. CodeIgniter Cron Job through Cpanel

    It seem to be a issue from path I had used. On cpanel before I had

    php --silent http://mysubdomain.mydomain.co.nz/cron/message
    

    That was not working proper if I wanted to use this code to prevent access

    if (!$this->input->is_cli_request()) {
       show_error('Direct access is not allowed');
    }
    

    So now I changed to

    php-cli /home/myusername/public_html/mysubdomain/index.php Cron message
    

    All works fine now

提交回复
热议问题