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

shylor's avatar
Level 12

Needing scheduling to run in maintenance mode.

Our team is currently using the maintenance mode as a coming soon page for our project. Some closed beta testers are using the page, and we need to run some schedules and jobs while it's in maintenance mode.

We figured out how to force the jobs to run, but we can't figure out why our schedule is not running or how to keep it running.

We are using Laravel 11 on Forge with Envoyer.

This is our schedule in routes/console.php

Schedule::command('communities:update-scores')
    ->hourly()
    ->thenPing('http://beats.envoyer.io/heartbeat/{hidden}');
0 likes
1 reply
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

In Laravel, when your application is in maintenance mode, scheduled tasks do not run by default. However, you can configure your scheduled tasks to run even when the application is in maintenance mode by using the evenInMaintenanceMode() method on your scheduled tasks.

Here's how you can modify your schedule in routes/console.php to ensure it runs while the application is in maintenance mode:

use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schedule;

Artisan::command('schedule:run', function () {
    $schedule = app(Schedule::class);

    $schedule->command('communities:update-scores')
        ->hourly()
        ->evenInMaintenanceMode()
        ->thenPing('http://beats.envoyer.io/heartbeat/{hidden}');
});

By adding ->evenInMaintenanceMode(), you instruct Laravel to execute this scheduled task regardless of the maintenance mode status.

Make sure you have set up your cron job to call php artisan schedule:run every minute, as this is necessary for Laravel's task scheduling to work.

Additionally, ensure that your server's cron job is correctly configured to execute the Laravel scheduler. You can typically do this by adding the following line to your server's crontab:

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

Replace /path-to-your-project with the actual path to your Laravel application. This setup will ensure that your scheduled tasks are checked every minute and executed as per their defined schedule, even when the application is in maintenance mode.

Please or to participate in this conversation.