2016-06-27 3 views
2

私のアプリケーションでは、毎日の更新のためにcronジョブを設定する必要があります。私はここで cronジョブ戻るログインページhtml in codeigniter

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

    } 
} 

であると私は

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

しかし、この戻りのようcpenalにパスを設定している私のconfig.phpファイルCodeIgniterの3.0

を使用していますアプリのフロントページでもあるログインページのhtml。 パスに問題があると思います。どうすれば修正できますか?

答えて

2

あなたのコードと私の実際のCI3 cronjobsの主な違いは2つあります。

まず、if (!$this->input->is_cli_request()){の代わりにif (is_cli())を使用します。

第二に、そしてサーバーの設定によって異なりますが、私はここに持っているとしては/ usr/bin/php-cliを追加してみてください可能性があります

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

これは

を助け場合は私に知らせてください
+0

ありがとうございました。 -cliは動作します。 –