Framework: Task Scheduler between is acting as unlessBetween

Created on 10 Jan 2018  路  3Comments  路  Source: laravel/framework

  • Laravel Version: 5.5.14
  • PHP Version: 7.0.26
  • Database Driver & Version: MySQL 5.5.52-MariaDB-38.3

Description:

When using the Laravel Task Scheduler I'm facing a problem when using the 'between' parameter.
I've got the following

  $schedule->command('route:call import/start')
            ->everyFifteenMinutes()
            ->between('22:00', '03:00')
            ->withoutOverlapping()
            ->appendOutputTo(storage_path() . '/logs/import/'.date('Y/m/d').'/start_ ' . date('H').'.txt');

So I expect to run it every 15 minutes between 22:00 and 03:00. However, it runs every 15 minutes EXCEPT when its between 22:00 and 03:00.

Every other scheduled task like 'dailyAt('22:00')' is working like expected.

Steps To Reproduce:

Most helpful comment

Why is this closed? Can see it as a common use case and a workaround isn't a fix.

EDIT: a better workaround is to just append +1 day to the end of the end time. Which I think is probably a good enough workaround to not need any sort of fix.

All 3 comments

We call Carbon::between which swaps the arguments around. Your code becomes 03:00 - 22:00 because of this.

A workaround would be to add two between intervals, 22:00-23:59 and 00:00-03:00.

I had the same problem before, and I ended up using the same workaround @sisve proposed.
That may not be ideal, but I've seen worse.

Why is this closed? Can see it as a common use case and a workaround isn't a fix.

EDIT: a better workaround is to just append +1 day to the end of the end time. Which I think is probably a good enough workaround to not need any sort of fix.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

YannPl picture YannPl  路  3Comments

klimentLambevski picture klimentLambevski  路  3Comments

ghost picture ghost  路  3Comments

SachinAgarwal1337 picture SachinAgarwal1337  路  3Comments

lzp819739483 picture lzp819739483  路  3Comments