I am working on a Laravel project and have created a command with signature ‘process:pending-reports’.
When I run this using: php artisan process:pending-reports
, it does the needful i.e. the script gets executed.
I have now added this to the schedule() method inside app/Console/Kernel.php file as so:
protected function schedule(Schedule $schedule)
{
$schedule->command('process:pending-reports')->everyFifteenMinutes();
}
When I check the details using:
php artisan schedule:list
I again get the expected output like:
*/15 * * * * php artisan process:pending-reports ................................................................................................... Next Due: 7 minutes from now
However, once the time for command execution passes, it does not actually run the command.
What am I missing?
2
Answers
The Laravel Scheduler must be added to the crontab:
you can edit it using the command:
then add a line like this:
Here is the reference
Command
php artisan schedule:list
just listing your scheduled task, not running the task.For running scheduled task on local development, you can use command
php artisan schedule:work
. This command will run in the foreground and invoke the scheduler every minute until you terminate the command.source:
Laravel Task Scheduling