Closed gamadoleo closed 6 years ago
Hi, the limitation comes from the crontab and there is no built-in functionality to run in less then a minute. That being said, you can run the scheduler multiple times with a sleep between each execution.
<?php
$scheduler = new Scheduler;
$scheduler->php('myscript.php');
$scheduler->run();
sleep(15);
$scheduler->resetRun()->run();
sleep(15);
$scheduler->resetRun()->run();
sleep(15);
$scheduler->resetRun()->run();
Of course this solution only works if your jobs run in less than a second (you might get fancy and calculate the time it takes on each run and adjust the sleep time).
@peppeocchi I have tried the following and it works, could be added to the docs or even implemented as run at second:
<?php
$this->scheduler->php($this->documentRoot, null, ['/cli/task/run' => ''])->everyMinute()->before(
function (): void {
sleep(5);
}
);;
is there any way to use this library to run tasks in less time every minute? ie every 15 seconds for example?