2016-08-31 11 views
3

こんにちは私はLaravelcronジョブ - LARAVEL - OUTPUT

protected function schedule(Schedule $schedule) 
{ 
    echo "test CRON JOB\n"; 
    $file1 = '1.log'; 
    $file2 = '2.log'; 
    $schedule->command('command1')->sendOutputTo($file1); 
    $schedule->command('command2')->sendOutputTo($file2); 

} 

cronジョブでLaravel

関数宣言でcronジョブを実行している -

pathToArtisan schedule:run 2>&1 >> /home/log/cron_output.log 

ログファイルの出力(cron_outputを設定します。ログ)

test CRON JOB 
Running scheduled command: '/opt/alt/php55/usr/bin/php' 'artisan'command1 > '1.log' 2>&1 & 
Running scheduled command: '/opt/alt/php55/usr/bin/php' 'artisan' command2 > '2.log' 2>&1 & 

関数スケジュールのエコーが表示されますが、コマンド1とコマンド2のエコーは表示されません。

私は

echo "test"; $this->info('test'); 

を試したんファイルは任意のアイデアを1.logないか2.logどちらも/家庭作成した場所/ログ/またはどこKernel.phpファイルがあるか、Commandフォルダ

あなたはLaravelにビルトインtask outputメソッドを使用する必要がありますあなたの

+0

あなたのコマンドは、出力テキストになど 'ます$ this->インフォ( 'テスト')'、 'ます$ this->エラー( 'テスト')'、使用する必要があります、ありがとうございました。 – ceejayoz

+1

何も変更されていないようです。 –

答えて

9

ありがとうございます。例えば

$file = 'command1_output.log'; 
$schedule->command('command1') 
     ->sendOutputTo($file); 
+1

ありがとうございます。私の場合、私は 'appendOutputTo'を好む。 – JCarlos

0

すべてが今okです。

$schedule->command('command1') 
    ->sendOutputTo($file); 

と私はそれらを見ていないので、ファイルは自分のアプリケーションのルートフォルダに作成され

$this->info('test') 

あなたのコマンドの内部!