In Laravel, you can specify the maximum execution time for a job by setting the timeout
property of the job class.
Here are the steps to specify the maximum execution time for a job in Laravel:
timeout
property. By default, it is set to the value specified in the config/app.php
file as QUEUE_TIMEOUT
. If not specified, it falls back to the default config/queue.php
file value as null
.
/**
* The number of seconds the job can run before timing out.
*
* @var int|null
*/
public $timeout = 60;
timeout
property according to your requirement. The value is in seconds. For example, if you want to set the maximum execution time to 120 seconds (2 minutes), you can set it like this:
public $timeout = 120;
By setting the timeout
property, you are specifying the maximum number of seconds a job can take to complete before Laravel considers it as timed out and terminates it. Keep in mind that setting a very large value for timeout
may result in the job consuming server resources excessively.