Given the following snippet:
$schedule->call(function () {
// echo "HELLO 123"; // nope
// return "HELLO 123"; // also nope
})
->everyMinute()
->sendOutputTo(storage_path('logs/cron/hello.cron.log'))
->emailOutputTo('[email protected]');
The scheduled task is running, the emails are being generated, but with no content. I can capture output via the $schedule->exec
and $schedule->command
.
Ideal end state here is, run a few internal, non-command processes within the call
method and output the results into a file/email.
I just googled the documentation of the class you are using with the words laravel scheduled output
and the documentation (Just above the anchor in a red box) states:
Note: The emailOutputTo and sendOutputTo methods are exclusive to the
command method and are not supported for call.
Hope that helps.
The accepted answer got me to the solution, but for future reference:
$schedule->call(function () {
// Do stuff
// Report to file
\Storage::append('logs/cron/hello.cron.log', "HELLO 123");
})->everyMinute();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With