KenoKivabe

Your Essential Queries

Author
Md Mojahedul Islam
28 Feb, 2023

How To Run The queue:work Command All The Time On Your Laravel Application in cPanel


To run the queue:work command all the time on your Laravel application in cPanel, you can follow these steps:

1) SSH into your cPanel account using your preferred SSH client.

2) Navigate to the root directory of your Laravel application.

3) Run the following command to start the queue:work command in the background and redirect its output to a log file:This command will start the queue:work command in daemon mode and redirect its output to the null device so that it does not clutter your log files.

  1. nohup php artisan queue:work --daemon > /dev/null &  

4) To ensure that the queue:work command is always running, you can create a cron job that checks if the command is running and restarts it if it is not. To do this, create a new cron job in cPanel with the following command:

  1. * * * * * ps aux | grep '[q]ueue:work' || nohup php artisan queue:work --daemon > /dev/null &  

5)This cron job will run every minute and check if the queue:work command is running. If it is not, it will start the command in daemon mode using the nohup command and redirect its output to the null device.

Note that the grep command is enclosed in square brackets to exclude itself from the search results, as it will also appear in the list of running processes.

With these steps, your queue:work command will run continuously on your Laravel application in cPanel, ensuring that your queued jobs are processed in a timely manner.


Share: