Frank Lucas
Frank Lucas

Reputation: 611

Lumen task scheduling everyMinute isn't working?

I have setup a command that generates a PDF with some stats and it sends the pdf as an attachment in an email. The command works great when I run t manually in my console.

php artisan send:report

Now I am trying to setup that this command is executed every last day of the month. To test I have setup the scheduler to everyMinute but when I run php artisan schedule:run the email is sent only 1 time when I run the command and not every minute.

Am I doing something wrong here?

My Kernel.php file in Lumen

<?php

namespace App\Console;

use App\Console\Commands\SendReport;
use Illuminate\Console\Scheduling\Schedule;
use Laravel\Lumen\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        SendReport::class,
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('report:send')->everyMinute();
    }
}

Am I missing something ?

Any help is greatly appreciated !

Many thanks in advance !

Upvotes: 0

Views: 6822

Answers (3)

sunomad
sunomad

Reputation: 1793

I think you need to set the entry in the crontab. See here: https://laravel.com/docs/5.4/scheduling and scroll down to Starting The Scheduler.

Upvotes: 2

Lee
Lee

Reputation: 3104

Please ensure this is on your server Cron entries as described in the docs

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

Upvotes: 3

Frank Lucas
Frank Lucas

Reputation: 611

Need to add a cronjob to run the schedule:run command:

Found answer in this issue.

Upvotes: 0

Related Questions