Daniel
Daniel

Reputation: 243

Get executed scheduled tasks in laravel 5.1

In Kernel.php I have several tasks that runs once or twice a day.

When I call php artisan schedule:run in the console I can see a response with "No scheduled commands are ready to run" or "Running scheduled command: xxxx".

I want to retrieve this messages to store them while running function schedule(Schedule $schedule){} in Kernel.php

The last think I tried is using ob_start(); and ob_get_contents(); but theese only returns my own echo();.

Adding ->getSummaryForDisplay() to the register command line doesn't display if a command was executed or not.

Upvotes: 0

Views: 882

Answers (1)

MaGnetas
MaGnetas

Reputation: 5108

You can get the output as described here:

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

to save the output to a file. Or:

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

to append it to a file.

You can also get the output by email but I believe you'll still have to use a file as well.

Upvotes: 1

Related Questions