How to configure a delay between job retries in Laravel?

In Laravel, you can configure a delay between retries for jobs using the retryAfter method provided by the Illuminate\Bus\Queueable trait. Here's how you can do it:

  1. Open your job class file (Usually located in the app/Jobs directory).

  2. Add the Queueable trait to your job class:

use Illuminate\Bus\Queueable;
  1. Then, use the retryAfter method in your job class's retry method to specify the delay in seconds. For example, if you want to retry the job after a delay of 10 seconds, you can set retryAfter(10):
public function retry($delay = null) { $this->retryAfter(10); }
  1. Make sure you have the tries property declared in your job class. It represents the maximum number of times a job will be attempted before being marked as failed:
public $tries = 3; // Example: Retry the job 3 times before marking it as failed

That's it! With these changes, your job will be retried after the specified delay between retries.