Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

meredevelopment's avatar

Missunderstanding php artisan schedule:run use

Hi, I'm playing about with Jobs and scheduling. I'm trying to understand the way the scheduler respects the timing options like everyMinute() or daily(). At the moment I can't get the delay/schedule to be respected at all.

Scenario 1:

If I have this in Kernel.php:

protected function schedule(Schedule $schedule)
{
    $schedule->job(new ProcessThing)->everyMinute();
}

...and I have a job called ProcessThing at app/Jobs/ProcessThing.php with this handle:

public function handle()
{
    logger('ProcessThing fired');
}

...when I start php artisan queue:work and run php artisan schedule:run, the response is: Running scheduled command: App\Jobs\ProcessThing

and [timestamp] local.DEBUG: ProcessThing fired gets written to the log file.

Problem 1: That looks ok... but if I try php artisan schedule:run 5 times in quick succession, the process runs 5 times immedialtey. I'd have expected it to queue into the Jobs table, and fire every minute?

Scenario 2:

If I now change the schedule to this:

    $schedule->job(new ProcessThing)->everyFiveMinutes();

(after restarting the worker and flushing config just to be safe) If I now run php artisan schedule:run, the response is: No scheduled commands are ready to run.

Problem 2: I'd expected the job to be added to the jobs table, with an 'available' timestamp 5 mins from now. If I wait 5 mins and try php artisan schedule:run again, the job never gets queued or runs, and nothing is ever logged.

I think I'm fundamentally missunderstanding this scheduling thing, but can't see where. Please help if you can.

0 likes
1 reply
Tippin's avatar

@meredevelopment The scheduler is "dumb" in the sense that it does not know how many times it was called within one minute. What is actually happening is when you call the schedule command, it matches the time on the server and sees if anything matches, and everyMinute() would be called every time you ran it as the time matches a minute of any hour, where everyFiveMinutes would only run at any 5min interval of an hour (1pm, 1:05pm, 1:10pm, etc). If you ran it twice at 1:05pm, you would have fired off twice (everyMinute and everyFiveMinutes). Daily runs when the time matches 12am. The goal is to setup a cronjob that runs the artisan schedule command once per minute on your server. Running locally and triggering manually will always cause the everyMinute to fire, or any matching "times". everyTenMinutes added in would fire all 3 (minute, 5 minute, 10 minute) if the time were 1:10.

Setup the cronjob to hit it once per minute and you are golden :

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

Please or to participate in this conversation.