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!
Leave a reply