In my project, I've made a simple newsletter system where I want to send an email to all subscribers. But the problem I faced in production (Cpanel hosting) I have to run laravel queue:work
command in terminal. Can anyone tell me how to handle queue:work
in background in CPanel hosting...
can anyone tell me how to handle this problem?
For sending the mail I'm using the cpanel mail smtp not using any other third party like mailchimp or mailgun etc...

- 1,159
- 1
- 17
- 29
-
Check [this](https://stackoverflow.com/questions/52273132/how-to-run-queue-worker-on-shared-hosting) and [this](https://stackoverflow.com/questions/46141652/running-laravel-queuework-on-a-shared-hosting) – iamab.in Nov 16 '20 at 12:11
1 Answers
**find crob job tab into your cpanel then set the cron job ** like
- daily
- after 5minutes or whatever you want
make a job to handle the user news letters like
php artisan make:job UserNewsLetters
and then make a email
php artisan make:mail NewsLetterEmail
make a view into mail/newsletter access the mailabel into your job set cron job path to your project folder like this /usr/local/bin/php /home/hosting_user/public_html/artisan queue:work or you can utilize laravel console commands https://laravel.com/docs/8.x/scheduling
please check this image and set cron job not run commandline
add this command into your cron task with full php path
php /path/to/laravel/artisan queue:work --stop-when-empty
to check php path run this in commandline
which php
cron task have these options to run your job 1-once per minute (mean job only run once in one minute so once per minute mean it will run 60 times in One Hour) 2-Every day mean once in 24hr 3- weekly job run once in a week
you can also make console commands for schedule your task and laravel have clear documentation Task Scheduling

- 549
- 3
- 8
-
Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackoverflow.com/rooms/224674/discussion-on-answer-by-tameemahmad-shahzad-laravel-queue-queuework-running-in). – Samuel Liew Nov 17 '20 at 12:57