
Laravel: Set Up Crontab and Supervisor Queue on Server
Learn how to configure Laravel Scheduler with crontab and run Laravel Queue Worker automatically using Supervisor on a Linux server.
When deploying a Laravel application to a server, two important parts are often missed:
Laravel Scheduler will not run automatically unless crontab is configured.
Laravel Queue Worker will not keep running in the background unless you use Supervisor or another process monitor.
Laravel Scheduler only needs one cron entry on the server. That cron entry runs php artisan schedule:run every minute, while the actual scheduled tasks are defined inside the Laravel application.
For queues, Laravel recommends using queue:work and keeping it alive with a process monitor such as Supervisor.
1. Set Up Crontab for Laravel Scheduler
Laravel Scheduler lets you define scheduled tasks inside your Laravel code.
Example:
use Illuminate\Support\Facades\Schedule;
Schedule::command('emails:send')->daily();But to make the scheduler run on your server, you need a cron job.
Step 1: SSH into your server
ssh username@your-server-ipStep 2: Check your PHP path
which phpExample result:
/usr/bin/phpOr for a specific PHP version:
/usr/bin/php8.2Step 3: Add the cron entry
There are two common ways.
Option 1: Use the current user crontab
crontab -eAdd:
* * * * * cd /path/to/your-project && /usr/bin/php artisan schedule:run >> /dev/null 2>&1Example:
* * * * * cd /home/vagrant/gts_system && /usr/bin/php8.2 artisan schedule:run >> /dev/null 2>&1Option 2: Edit /etc/crontab
sudo nano /etc/crontabFor /etc/crontab, include the username:
* * * * * username cd /path/to/your-project && /usr/bin/php artisan schedule:run >> /dev/null 2>&1Example:
* * * * * root cd /home/vagrant/gts_system && /usr/bin/php8.2 artisan schedule:run >> /dev/null 2>&1Important note
This part:
>> /dev/null 2>&1redirects both output and errors to /dev/null.
Test the Scheduler
Run:
cd /path/to/your-project
php artisan schedule:runOr list scheduled tasks:
php artisan schedule:list2. Set Up Laravel Queue Auto-run with Supervisor
Laravel queues are used for background jobs such as:
Sending emails
Processing notifications
Exporting files
Importing data
Syncing APIs
Running heavy tasks
If you run:
php artisan queue:workdirectly in a terminal, the worker will stop when the terminal closes.
That is why production servers should use Supervisor to keep the worker running in the background.
Step 1: Install Supervisor
sudo apt update
sudo apt install supervisorStart Supervisor:
sudo systemctl start supervisorEnable Supervisor on system startup:
sudo systemctl enable supervisorStep 2: Create a Supervisor config file
sudo nano /etc/supervisor/conf.d/laravel-worker.confYou can name the config file based on your project:
sudo nano /etc/supervisor/conf.d/gts-worker.confStep 3: Configure the worker
Basic config:
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
directory=/path/to/your-project
command=/usr/bin/php artisan queue:work --sleep=3 --tries=3 --timeout=90
autostart=true
autorestart=true
user=your-username
numprocs=1
redirect_stderr=true
stdout_logfile=/path/to/your-project/storage/logs/worker.log
stopwaitsecs=3600Example:
[program:gts-worker]
process_name=%(program_name)s_%(process_num)02d
directory=/home/vagrant/gts_system
command=/usr/bin/php8.2 artisan queue:work --sleep=3 --tries=3 --timeout=90
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/home/vagrant/gts_system/storage/logs/worker.log
stopwaitsecs=3600Step 4: Reload Supervisor
sudo supervisorctl reread
sudo supervisorctl updateStart the worker:
sudo supervisorctl start gts-worker:*Check status:
sudo supervisorctl statusQueue:work vs Queue:listen
Some guides use:
php artisan queue:listenHowever, for production, prefer:
php artisan queue:workqueue:listen can reload code changes automatically, but Laravel docs note that it is significantly less efficient than queue:work.
Recommended setup:
Development:
queue:listenis acceptableProduction:
queue:work+ SupervisorAfter deployment: run
php artisan queue:restart
php artisan queue:restartSupervisor will restart the worker after it exits safely.
Final Checklist
After setup, check:
php artisan schedule:list
php artisan schedule:run
sudo supervisorctl status
tail -f storage/logs/worker.log
tail -f storage/logs/laravel.logIf the queue worker is not running, verify:
Project path
PHP binary path
File permissions
.envqueue connectionSupervisor config
Worker log
Conclusion
When deploying Laravel to a server, you should configure both:
Crontab for Laravel Scheduler
Supervisor for Laravel Queue Worker
Crontab keeps scheduled tasks running every minute.
Supervisor keeps long-running queue workers alive in the background.
These two small configurations make Laravel applications much more stable in production.
CTA
If your Laravel app is already on a VPS or production server, check whether schedule:run is configured in crontab and queue:work is managed by Supervisor. Missing either one can cause scheduled tasks or queued jobs to silently stop working.