Issue
Hi I'm running CRON JOB with Laravel
Function declaration in Laravel
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 JOB - Setting
pathToArtisan schedule:run 2>&1 >> /home/log/cron_output.log
Log file output (cron_output.log)
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 &
The echo in the function schedule is displayed but the ones inside my command 1 and command 2 are not.
I tried
echo "test"; $this->info('test');
No files 1.log or 2.log where created neither /home/log/ or where the Kernel.php file is or Command folder
Any ideas ?
Thank you
Solution
You should use the built-in task output method in Laravel.
For example:
$file = 'command1_output.log';
$schedule->command('command1')
->sendOutputTo($file);
Answered By - avip Answer Checked By - Dawn Plyler (WPSolving Volunteer)