Laravel - Task Scheduling - Task Output

The Laravel scheduler provides several convenient methods for working with the output generated by scheduled tasks. First, using the sendOutputTo method, you may send the output to a file for later inspection:

    
    $schedule->command('emails:send')
             ->daily()
             ->sendOutputTo($filePath);
	

If you would like to append the output to a given file, you may use the appendOutputTo method:

    
    $schedule->command('emails:send')
             ->daily()
             ->appendOutputTo($filePath);
	

Using the emailOutputTo method, you may email the output to an email address of your choice. Before emailing the output of a task, you should configure Laravel's email services:

    
    $schedule->command('report:generate')
             ->daily()
             ->sendOutputTo($filePath)
             ->emailOutputTo('[email protected]');
	

If you only want to email the output if the scheduled Artisan or system command terminates with a non-zero exit code, use the emailOutputOnFailure method:

    
    $schedule->command('report:generate')
             ->daily()
             ->emailOutputOnFailure('[email protected]');
	
The emailOutputTo, emailOutputOnFailure, sendOutputTo, and appendOutputTo methods are exclusive to the command and exec methods.