Laravel >= 5.7
Adding this line to the scheduler in app\Console\Kernel.php and then setting up a cron job to run the scheduler, ensures that the queue gets serviced every minute.
$schedule->command('queue:work --stop-when-empty')
->everyMinute()
->withoutOverlapping();
For Cpanel servers, the Cron statement might look like:
* * * * * /usr/local/bin/php /home/{account_name}/live/artisan schedule:run
where {account_name} is the user account that cpanel is running under and live is the folder of the laravel application
Source: https://talltips.novate.co.uk/laravel/using-queues-on-shared-hosting-with-laravel
Laravel <= 5.6
--once
To force worker to exit after running one job
--tries
The maximum number of times a job may be attempted
--timeout
The maximum number of seconds that jobs can run may be specified
withoutOverlapping()
By default, scheduled tasks will be run even if the previous instance of the task is still running. To prevent this, you may use the withoutOverlapping method
sendOutputTo()
Send the output to a file for later inspection
$schedule->command('queue:work --timeout=60 --tries=1 --once')
->everyMinute()
->withoutOverlapping()
->sendOutputTo(storage_path() . '/logs/queue-jobs.log');
Laravel All version
If you don't want to use the `--once' or '--max-time' options, it's better to use the restart command to avoiding memory leak and make apply code changes.
$schedule->command('queue:restart')
->everyFiveMinutes();
Laravel <= 5.2
Not recommended:
The --daemon options continued to run, which you can run once from the command line if you have ssh or cpanel 'command' access.