The topic was raised again for Yii3 about having a scheduler package. Schedulers are common: both Laravel and Symfony have one. But in most cases, you don't need it.
Laravel runs
schedule:run from cron every minute. schedule:work just replaces cron as the trigger. Either way, the framework boots 1440 times a day, mostly to find nothing to do.Symfony uses a worker that never stops instead, which is one more process to watch, restart after deploys, and keep from leaking memory. Way better, but still not really necessary.
The main argument for these is "the schedule is in the repository". But a
crontab file can be there as well, and cron tools already cover the features:- No overlap:
flock -n.- Missed runs: anacron, or systemd timers with
Persistent=true.- Monitoring: ping your monitoring service from the command.
- Containers: supercronic.
PHP-based schedulers also have a significant drawback: both run tasks one by one by default. You need
runInBackground or a queue to fix that. Cron starts all the 8:00 jobs at 8:00.A scheduler makes sense for tasks that run more often than once a minute, schedules stored in a database, one-server execution with failover, or hosting without cron.
Otherwise, just use cron.
What do you think about PHP schedulers?
#php #cron #laravel #symfony #devops #yii3 #yii