Edit laravel-worker.conf file using following command:
sudo vim /etc/supervisor/conf.d/laravel-worker.conf
And then insert the following code:
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/yourdomain.com/artisan queue:work
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=root
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/html/yourdomain.com/worker.log
stopwaitsecs=3600
Don't forget to change your domain name and other paths as per your OS (above code is for Ubuntu).
After this, run following commands in the terminal:
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start laravel-worker:*
That's it. If you don't have "Supervisor" installed then you need to run following commands:
sudo apt-get install supervisor
sudo service supervisor restart
If you want to check the status of "Supervisor" please run the following command:
sudo supervisorctl status
If you want to remove the "Supervisor" please run the following commands:
sudo apt-get remove supervisor
sudo apt-get autoremove