1
votes

1 Queue with Database drivar.My queue:work command run on everyminute.

I want to execute the job for max 2 attempts and it is working. but the issue is my Queue:work cron runs on every minute and even if the earlier job is in progress it attempts for same job.

How can I avoid the queue:work command to run the in-progress job.

Thanks

1

1 Answers

0
votes

queue:work will not try to perform a job that is already being performed since it gets reserved flag at the start of the process. What you might be experiencing is the fact that your job is failing before the next time Cron executes, so it just tries the same job again forever.

You can use --tries everytime you invoke queue:work to limit the amount of attempts a job will have. So if you run php artisan queue:work --tries=2, the job will be attempted to execute 3 times and, if it fails all 3 times, it gets added to the failed_jobs table.

Make sure you have prepared your environment (database migration) with php artisan queue:failed-table.