Search code examples
phplaravellaravel-5cronscheduling

Laravel Scheduling conflicts with multiple calls


I am using Laravel Task Scheduling

I need to run multiple tasks at different times, like this:

protected function schedule(Schedule $schedule) {
    $schedule->call('App\Http\Controllers\SomeController@job1')->daily();
    $schedule->call('App\Scheduled\SomeClass@job2')->hourly();
    $schedule->call('App\Scheduled\SomeClass@job3')->hourly();
    $schedule->call('App\Scheduled\SomeOtherClass@job4')->daily();
}

But for some reason everything runs once a day (at 12:00am). What am I doing wrong?


Solution

  • That sounds like your cron job is only running artisan schedule:run once per day. Make sure your cron job is set up like the docs:

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

    The * * * * * part means run every minute, and then Laravel will decide which tasks to run each minute based on your schedule.