Skip to content

Instantly share code, notes, and snippets.

@Lysak
Last active April 14, 2025 13:41
Show Gist options
  • Save Lysak/b98f2ac629f4bc71511b3c3f84558d66 to your computer and use it in GitHub Desktop.
Save Lysak/b98f2ac629f4bc71511b3c3f84558d66 to your computer and use it in GitHub Desktop.
laravel queue crontab with logging example
* * * * * cd /var/www/html2/laravel && sleep 5 && ./vendor/bin/sail php artisan queue:work --sleep=3 --tries=2 --max-time=3600 --stop-when-empty >> /var/www/html/laravel/storage/logs/crontab.log 2>&1
@Lysak
Copy link
Author

Lysak commented Apr 14, 2025

Laravel Queue Worker via Cron (with Docker Sail)

This cron job runs every minute to process Laravel queued jobs using Docker Sail. It includes a 5-second delay before starting and is configured to:

Sleep 3 seconds between job attempts

Retry failed jobs up to 2 times

Stop after 1 hour or when the queue is empty

Log all output (including errors) to crontab.log in the Laravel storage logs directory

Useful for lightweight queue management in containerized Laravel projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment