Laravel schedule not respecting time

378 Views Asked by At

I am using Laravel 9 and I am trying to set several tasks in my schedule. One of them should be called every minutes the other every 5 minutes .

    protected function schedule(Schedule $schedule)
    {
       $schedule->call(/* send myself a mail */)->everyMinute();
       $schedule->call(/* send myself a mail */)->everyFiveMinutes();
    }

On my host I have a cron task called every minutes :

/opt/alt/php81/usr/bin/php ~/my-path/artisan schedule:run

However every minutes I receive the mail from my everyMinute() task, and the mail from my everyFiveMinutes() task.

I tried with job and command instead of call but it doesn't changes anything, same with ->cron('* * * * *') instead of ->everyMinute()

1

There are 1 best solutions below

0
exefire On

I had the very same issue.

I discover that when I use the schedule like this:

$schedule->call( MyController::MyFunction() )->everyFiveMinutes();

It run every minute, not every 5 minute as it would suppose to run.

If I run like this, every works as expect:

$schedule->call(function () {MyController::MyFunction();})->everyFiveMinutes();