Thursday, March 16, 2017

Scheduling jobs every N minutes at diferent days

I have to run a cronjob in particular times:

First one: weekdays between 9:00 - 18:00 every 2 minutes

Second one: saturdays between 10:00 - 18:00 every 2 minutes

The farthest I could get is this:

$schedule->call(function () {
    (new SendSMS())->run();
})->weekdays()->between('9:00', '18:00');

I dont know how to add the everyTwoMinutes constraint since I only found these methods:

->everyMinute();    
->everyFiveMinutes();
->everyTenMinutes();
->everyThirtyMinutes();

And the second problem is that for the second condition I dont want to add another schedule like these:

$schedule->call(function () {
    (new SendSMS())->run();
})->saturdays()->between('11:00', '18:00');

I would to write a single one matching both times, is it possible?



via Alan

Advertisement