Skip to content

Instantly share code, notes, and snippets.

@SeyamMs
Last active January 18, 2025 17:05
Show Gist options
  • Save SeyamMs/8c897aa5c201449499056b90b900962c to your computer and use it in GitHub Desktop.
Save SeyamMs/8c897aa5c201449499056b90b900962c to your computer and use it in GitHub Desktop.
laravel scheduler crontab and supervisor configuration file
# 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