CRON JOB - LARAVEL - EXIT

Hi, I am 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 - Setup

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 &

An echo is displayed in the function schedule, but inside my command 1 and command 2 are not.

I tried

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

There are no 1.log or 2.log files where neither / home / log / was created, or where the Kernel.php file is located, or the command folder

Any ideas?

thank

+4
source share
2 answers

You must use the built-in task output in Laravel.

For instance:

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

Now everything is all right.

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

and inside your team

$this->info('test')

Files are created in the root folder of my application, so I did not see them!

thank

0
source

Source: https://habr.com/ru/post/1653074/


All Articles