0

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()

10
  • Are you running this Locally or remote? Commented May 11, 2022 at 15:05
  • I'm doing it remote Commented May 11, 2022 at 15:06
  • have you tried the command that laravel give? * * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1 Commented May 11, 2022 at 15:07
  • This is whats I was using before, but it wasn't working and never calls my schedule Commented May 11, 2022 at 15:12
  • Do you have cron installed on your machine? Commented May 11, 2022 at 15:14

1 Answer 1

0

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();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.