Home / Snippets / How to Persist Recent, Pending and Completed Horizon Jobs in Laravel for 24 Hours
How to Persist Recent, Pending and Completed Horizon Jobs in Laravel for 24 Hours cover

How to Persist Recent, Pending and Completed Horizon Jobs in Laravel for 24 Hours

1.4K

2 years ago

0 comments

Laravel Horizon by default has 1 hour "Job Trimming Times" for a successful job which means that after a job has been run the record will remain in the Horizon list for 1 hour and for the failed jobs, it will remain for 7 days.
  • Recent, Pending, Completed = 1 hour
  • Recent Failed, Failed, Monitored - 7 days
This number might be okay for some users but in my case, I need the "Recent, Pending, Completed" to at least remain for 1 day. To have it persist for 1 day you can update the horizon.php configuration and it's located within the trim key.
<?php // horizon.php

// other configs

'trim' => [
    'recent' => 1440, // 1 day
    'pending' => 1440, // 1 day
    'completed' => 1440, // 1 day
    'recent_failed' => 10080, // 1 week
    'failed' => 10080, // 1 week
    'monitored' => 10080, // 1 week
],
Now that you have set it up to the new value, you have to do is to terminate the horizon and then start it once again.
php artisan horizon:terminate

php artisan horizon
I hope you find this useful and cheers, happy coding!
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this