2016-03-01 140 views
0

我通過Laravel控制檯安排了一個cronjob。它正在努力並在每一分鐘內給出結果。但我試圖使用sendOutputToappendOutputTo方法將輸出寫入文件。但是這不是寫入文件。我的文件具有寫入權限。以下是我的代碼。sendOutputTo在Laravel控制檯

Kernel.php

protected function schedule(Schedule $schedule) { 

    $filePath = base_path() . "\cron\CleanSession.txt"; 

    $schedule->command('cleansession') 
      ->everyMinute() 
      ->sendOutputTo($filePath); 
} 

session.php文件

public function handle() { 

     $this->info('Display this on the screen'); 
     $onlineCodeObj = new OnlineCode(); 
     if ($onlineCodeObj->cleanSession()) { 
      echo "SESSION CLEANED : echo" . "\n"; 
      return "SESSION CLEANED: return" . "\n"; 
     } 
     echo "SESSION CLEANED : echo2" . "\n"; 
     return "SESSION CLEANED: return2" . "\n"; 
    } 

任何幫助表示讚賞。

回答

1

解決了這個問題。更改路徑

$filePath = base_path() . "\cron\CleanSession.txt";$filePath = base_path() . "/cron/CleanSession.txt";