Consider below is my kernel.php:
protected function schedule(Schedule $schedule) {
Log::info('Testing scheduler output');
$schedule->call(function () {
Log::info('Testing scheduler: ' . date("d/m/Y h:i:sa"));
});
exit;
}
I am trying to run the scheduler by below command :
php artisan schedule:run
Expected output is :
[current timestamp] local.INFO: Testing scheduler output
[current timestamp] local.INFO: Testing scheduler: <current_timestamp>
Actual output what I am getting is :
[current timestamp] local.INFO: Testing scheduler output
I am not able to understand why closure function's log is not generated or that code is not executed
CodePudding user response:
Remove the exit;
line from the end of your schedule
method, you don't need that.
You are registering the closure command, but Laravel is not executing it right away.
Laravel registers your schedule in the Kernel when the framework boots from console, and then the schedule:run
console command executes those separately. You are calling exit
before Laravel has a chance to execute tasks.