0

I have a scheduled command as such:

public function schedule(Schedulable $scheduler)
{
    return $scheduler->everyMinutes(1);
}

Is there a way to get this to run every ten seconds?

imperium2335
  • 23,402
  • 38
  • 111
  • 190

2 Answers2

0

If I understand correctly the scheduler in laravel is based on the cron format.

So you can not define a repetition smaller than minutes. You might use a workaround : link

Community
  • 1
  • 1
orestiss
  • 2,183
  • 2
  • 19
  • 23
-1

What you are thinking off is something called long-polling and it does not scale good on PHP especially when you use blocking IO.

Something like this:

set_timeout_limit(11);
$i=0;
while ($i<10) {
    i = i + 1;
    sleep(1); // sleep 1 second
}

Calling A PHP Function Every Second

Also:

https://stackoverflow.com/a/6488569/11926

Community
  • 1
  • 1
Sundaze
  • 195
  • 1
  • 3
  • 11