Frist run this migrations :
php artisan queue:table
php artisan queue:failed-table
php artisan migrate
create a job using artisan
php artisan make:job TestJob --queued
Then dispatch the job when appropriate
$job = (new TestJob($user))->delay(10);
$this->dispatch($job);
Create a "laravel-worker.conf" in /etc/supervisor/conf.d folder
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/app/artisan queue:work database --sleep=3 --tries=3 --daemon
autostart=true
autorestart=true
user=www-data
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/html/app/worker.log
After saving the file run these commands
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start laravel-worker:*