mardi 1 mars 2016

sendOutputTo in Laravel Console

I scheduled a cronjob through Laravel console. It is working and giving the result in every minute. But I tried to write the output to a file using the sendOutputTo and appendOutputTo method. But this is not writing to the file. My file has write permission. Below is my code.

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";
    }

Any help appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire