Replies: 2 comments
-
This has been added to 8.x via #38174 |
Beta Was this translation helpful? Give feedback.
0 replies
-
It's a bit unfortunate that these methods have to be implemented one by one instead of having a more fluid interface like what you can already do with $schedule
->job(\App\Jobs\DoSomething::class)
->hourly()
->at(17) Furthermore, sub-minute scheduling wouldn't have to have been specifically introduced (#47279) if we had something similar to the query builder's dynamic <?php
namespace Illuminate\Console\Scheduling;
trait ManagesFrequencies
{
const FREQUENCY_METHOD_REGEXP = '/^(?:(every)(\d{1,30})?(Second|Minute|Hour|Day|Week|Month|Year)(s)?|(twice|bi|tri)?(?i:hour|dai|week|month|quarter|year)(ly(At|On)?)?)$/'; // @todo overly simplified for presentation
public function __call(string $name, array $args)
{
if (preg_match(self::FREQUENCY_METHOD_REGEXP, $name, $matches)) {
return match() {
self::isEveryNth($matches) => $this->every(),
// ...
};
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
There is the method
twiceDaily()
already, but it will run the task at the full hour, which might be a problem.I always try to avoid running cron jobs at the full hour, but rather schedule it at some prime number minute, so there will not be a big peak in app server and database load, due to running a bunch of tasks and jobs at the same time.
So I suggest to introduce a twiceDailyAt() method, that would have two string parameters, like
twiceDailyAt('06:17', '18:17')
Beta Was this translation helpful? Give feedback.
All reactions