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

NoTimeForCaution's avatar

Forge | Schedule Model Pruning

I'm attempting a simple daily model prune as my first scheduled task. The site is in deployment with Forge. Unfortunately, the scheduled daily task is not being executed in production. Was wondering if I may be missing a step. I've followed docs as closely as possible. Code below for review.

Any idea as to why this isn't running? Thanks!

class Event extends Model
{
    use HasFactory, Prunable;

    public function prunable()
    {
        return static::where('date', '<', now()->subDay());
    }
}
// app/Console/Kernel.php

protected function schedule(Schedule $schedule)
    {
        $schedule->command('model:prune')->daily();
    }

And when I SSH into Forge server CLI

$ php artisan model:prune --pretend
3 [App\Models\Event] records will be pruned.

$ php artisan model:prune
3 [App\Models\Event] records have been pruned.

The 3 models above should have been pruned overnight but weren't.

0 likes
2 replies
Nakov's avatar
Nakov
Best Answer
Level 73

On your Forge server there is a Scheduler page which allows you to schedule a cron job that will run each minute. So you need to set that one to run your scheduled commands in the Kernel file:

https://forge.laravel.com/docs/1.0/resources/scheduler.html

https://snipboard.io/E2uq4c.jpg

php PATH_TO_YOUR_PROJECT/artisan schedule:run and create it.

Please or to participate in this conversation.