[7.x] Add "every 2 / 3 / 4 minutes" methods to scheduler#33379
Conversation
|
I think you may be better off running a custom expression for this: ->cron('* */2 * * *');
->cron('* */3 * * *');
->cron('* */4 * * *');
php |
|
I agree with browner12. Although it wouldn't necessarily be an issue including more methods. Your immediate problem can be resolved using a custom cron schedule. https://laravel.com/docs/7.x/scheduling#schedule-frequency-options |
|
I believe this is macroable as well |
|
As @browner12 said, you can currently achieve the same result by using a custom cron expression. But considering how cryptic the cron expression syntax is, you should probably always add a comment so the rest of your team can understand what's going on: $schedule->job(SyncSomething::class)->cron('*/2 * * * *'); // every 2 minutes
// or, with this PR
$schedule->job(SyncSomething::class)->everyTwoMinutes(); |
|
I think too many proxy methods don't make sense and the framework core code becomes more and more giant. |
|
Boy I wish I would have seen this, rather than adding all those proxy methods, I would have suggested using |
See #33380 |
This PR adds the following methods to the scheduler:
everyTwoMinutes()everyThreeMinutes()everyFourMinutes()These new methods go alongside the currently available
everyMinuteandeveryFiveMinutesmethods.I need these methods for an application that syncs data from a legacy system. We have to sync the data "in real time" (as in, so that it feels like "real time"). Using
everyMinuteseems like overkill, and might overload their server. On the other hand,everyFiveMinutesdoesn't feel "real time" enough. Being able to schedule the sync every 2 or 3 minutes would be perfect.Scheduling jobs that should run very often is a common use-case. These new methods give developers more choice in exactly how often.