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

Annaro's avatar

Restart queue worker (or server) after a certain number of jobs

When you start a worker in command line, you have the option to specify a maximum number of jobs after which the worker will exit:

php artisan queue:work --max-jobs=1000

How do you do this in Laravel Forge?

Those are the options for queues in Forge:

Connection
Queue
Maximum Seconds Per Job
Rest Seconds When Empty
Failed Job Delay in Seconds
Maximum Tries (Optional)
PHP Version
Environment (Optional)
Maximum Memory (Optional)
Working Directory (Optional)
Number of Processes (Optional)
Graceful Shutdown Seconds (Optional)
Run Worker As Daemon (Laravel 4.2+)
Always Run, Even In Maintenance Mode

I did check the Run Worker As Daemon checkbox, and made sure i included $FORGE_PHP artisan queue:restart in my deploy script.

After some time, my server reaches 100% CPU and 100% memory and my jobs start failing.

Is there any way to restart workers after a certain number of jobs?

Or, even better i guess, automatically restart the server after a certain number of jobs or after a certain period of time?

0 likes
1 reply
pionect's avatar

Was looking for the same setting, have you found a solution?

Please or to participate in this conversation.