skip to Main Content

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


  1. The Laravel Scheduler must be added to the crontab:

    you can edit it using the command:

    crontab -e

    then add a line like this:

    * * * * * cd /path/to/your/project && php artisan schedule:run >> /dev/null 2>&1
    

    Here is the reference

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search