Cron + queue
CartUser uses Laravel's scheduler to run background tasks (expire coupons, send emails, process subscriptions). One cron entry handles everything.
Cron setup
cPanel / Plesk
- Log in to cPanel.
- Go to Cron Jobs.
- Set frequency to Every Minute (or
* * * * *). - Command:
Replace path with your actual install path.cd /home/user/public_html/kode && php artisan schedule:run >> /dev/null 2>&1 - Save.
Linux server (SSH)
crontab -e
Add this line:
* * * * * cd /home/user/public_html/kode && php artisan schedule:run >> /dev/null 2>&1
Windows (Laragon dev)
Open Task Scheduler โ create basic task โ trigger every 1 minute โ action:
php D:\laragon\www\cartuser\kode\artisan schedule:run
What runs on schedule
| Task | Frequency | Purpose |
|---|---|---|
| Expire coupons | Daily | Mark expired coupons inactive |
| Expire reward points | Daily | Mark pending points expired |
| Process recurring subscriptions | Daily | Charge sellers, renew/cancel plans |
| Clean old sessions | Hourly | Garbage collection |
| Send queued emails | Every minute | Order confirmations, etc. |
| Send queued SMS | Every minute | OTPs, order alerts |
| Refresh exchange rates | Daily | Multi-currency price conversion |
| Auto-cancel unpaid orders | Hourly | Free up reserved stock |
Verify cron is running
cd /home/user/public_html/kode
php artisan schedule:list
Shows all scheduled tasks + next run time.
Queue worker (optional but recommended)
For high-volume stores, run a queue worker so emails/SMS don't slow down checkout:
1. Set queue driver
Edit kode/.env:
QUEUE_CONNECTION=database
Run migration:
php artisan queue:table
php artisan migrate
2. Start worker
php artisan queue:work --tries=3 --timeout=120
Keep this running. Use supervisord or systemd for production.
3. Supervisord example
; /etc/supervisor/conf.d/cartuser-worker.conf
[program:cartuser-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /home/user/public_html/kode/artisan queue:work --tries=3 --timeout=120
autostart=true
autorestart=true
user=www-data
numprocs=2
redirect_stderr=true
stdout_logfile=/var/log/supervisor/cartuser-worker.log
Restart worker after deploy
php artisan queue:restart
Daily backup cron (recommended)
Add second cron entry:
0 3 * * * cd /home/user/public_html/kode && php artisan db:backup >> /dev/null 2>&1
Runs daily at 3 AM โ saves to storage/app/backups/.
Troubleshooting cron
Tasks not running
- Verify cron entry exists:
crontab -l - Verify command path is correct (find PHP:
which php) - Run manually to check:
php artisan schedule:run - Check cron log:
tail -f /var/log/cron - Check Laravel log:
tail -f kode/storage/logs/laravel.log
Emails not sending
- Run queue worker manually:
php artisan queue:work --once - Check failed jobs:
php artisan queue:failed - Verify SMTP credentials in
.env - Test mail:
php artisan tinker --execute="Mail::raw('test', fn($m) => $m->to('[email protected]')->subject('test'));"