2016-06-27 31 views
2

在我的應用程序中,我需要爲每日更新設置cron作業。我使用笨3.0cron作業返回登錄頁面codeigniter中的html

我的config.php文件

$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設置路徑像

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

但這回也是應用程序首頁的登錄頁面的html。 我認爲路徑存在問題,那麼我該如何解決它?

回答

2

我看到您的代碼和我的工作CI3 cronjobs之間的兩個主要區別。

首先是我用if (is_cli())而不是if (!$this->input->is_cli_request()){

其次,可能取決於你的服務器設置,但嘗試添加-cli在/ usr/bin中/ PHP,因爲我在這裏:

/usr/bin/php-cli /home/public_html/index.php cron cron_job 

請讓我知道,如果這有助於

+0

非常感謝。 -cli工作。 –