lieroes
lieroes

Reputation: 694

How to execute laravel job (queue)?

developers, I have a problem. My queue not working or i just not understand how it's works. I create a command which should add a new queue job. Driver for Queue is - database. After executing my command i see a new row in table 'jobs'. After that I try to do "php artisan queue:work" - but nothing happens.

Help me please, how can I execute this job?

Upvotes: 16

Views: 75451

Answers (4)

Raskul
Raskul

Reputation: 2199

To delay the next retry just add --delay=[NUM_OF_SECONDS] to your command.

For example, to wait 30 seconds to retry after failing just

run: php artisan queue:work tries=3 --delay=30

OR

php artisan queue:work --daemon --tries=3 --sleep=5 --delay=10

Upvotes: 0

Abdulhakeem
Abdulhakeem

Reputation: 57

Yes there are times when your queue jobs won't run. For deployment if you are using redis queue driver, if not you can follow this here to install and configure redis and after which you should create a table for failed jobs using php artisan queue:failed-table php artisan migrate and then use php artisan queue:work redis --tries=3 --backoff=3 to retry every failed jobs 3 times after 3 seconds of failure.

Upvotes: 2

overburn
overburn

Reputation: 1234

Try

php artisan queue:listen

instead.

Upvotes: 5

Himanshu Bhandari
Himanshu Bhandari

Reputation: 1879

From the documentation : [Daemon Queue Listener] The queue:work artisan command includes a --daemon option for forcing the queue worker to continue processing jobs without ever re-booting the framework. This results in a significant reduction of CPU usage when compared to the queue:listen command:

To start a queue worker in daemon mode, use the --daemon flag:

php artisan queue:work connection --daemon

However if you don't have multiple connections remove connection and execute it without connection :

php artisan queue:work --daemon

It worked for me.

Upvotes: 14

Related Questions