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

thindery's avatar

Scheduled Commands run in Dev but not in Forge staging server

So I have my staging server on Forge. When ever I go to test things it is not running my kernel scheduled jobs.

here is what I have:

<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use App\Models\League;
use Carbon\Carbon;
use App\Models\FantasyTeam;
use App\Models\DraftOrder;
use Symfony\Component\Process\Process;


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

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

    
    protected function scheduleDraftOrderCommands(Schedule $schedule) 
  {
        
        $today = Carbon::now()->format('Y-m-d');
        
    $leagues =  League::where('draft_date','<>',null)                           
        ->where('draft_started',0)
      ->where('draft_date', '<', Carbon::now()->addMinutes(16)->toDateTimeString())
        ->where('online_draft',1)
        ->get();
            
        if(!empty($leagues)){
            foreach($leagues as $league){   
          $schedule->command('GenerateDraftOrder', ['--league_id' => $league->id])->name('GenerateDraftOrder '.$league->name);
            }
        }                       
  }

    protected function scheduleStartDraftCommands(Schedule $schedule)
  {
        
        $today = Carbon::now()->format('Y-m-d');
    $leagues =League::where('draft_date','<>',null)                         
        ->where('draft_started',0)
    ->where('draft_date', '<', Carbon::now()->addSeconds(90)->toDateTimeString())
        ->where('online_draft',1)
        ->get();
                        
        if(!empty($leagues)){
            foreach($leagues as $league){    
                $schedule->command('StartDraft', ['--league_id' => $league->id])->name('StartDraft '.$league->name)->runInBackground();
            }
        }                       
  }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}

When I run on my local dev I do the following in the command line to simulate a cron:

while true; do php artisan schedule:run; sleep 60; done

it works flawlessly on my dev.

However, it won't work on my Forge staging server. Forge is supposed to have CRONs running by default.

I have php artisan clear:cache on the stage server to see if it was that. But it didn't help.

If I manually run... php artisan schedule:run via ssh it does what it is supposed to do.

It's like the cron isn't running on my Forge stage server. So my questions:

  1. Should the above Kernel code run correctly?

  2. Any suggestions for how I can get this to run properly on Forge?

0 likes
1 reply
thindery's avatar

To answer my own question... the scheduler wasn't running in forge. I had to add a new one to run schedule:run

Please or to participate in this conversation.