Last active
January 18, 2025 17:05
-
-
Save SeyamMs/8c897aa5c201449499056b90b900962c to your computer and use it in GitHub Desktop.
laravel scheduler crontab and supervisor configuration file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# running the scheduler using crontabs (as mentioned in laravel docs) | |
add a cron job by opening the cron entry file with: | |
crontab -e | |
Then add the following entry to run the schedule every minute: | |
* * * * * cd /var/www/example.com && php artisan schedule:run >> /dev/null 2>&1 | |
Examine the Status of the Cron Service: | |
systemctl status cron | |
if your crontab is not working for whatever reason, then you can start this service by running the command below in your terminal: | |
sudo service cron start | |
# using supervisor (not mentioned in docs) | |
after installing supervisor (if not see: https://gist.github.com/SeyamMs/2da8fcfa678633dcf6bb2a801d1f3633) | |
nano /etc/supervisor/conf.d/scheduler.conf | |
[program:laravel-scheduler] | |
process_name=%(program_name)s | |
command=php /var/www/example.com/artisan schedule:work | |
autostart=true | |
autorestart=true | |
stopasgroup=true | |
killasgroup=true | |
numprocs=1 | |
redirect_stderr=true | |
stdout_logfile=/var/www/example.com/storage/logs/scheduler.log | |
stopwaitsecs=3600 | |
stdout_logfile_maxbytes=5MB | |
sudo supervisorctl reread | |
sudo supervisorctl update | |
sudo systemctl status supervisor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment