Laravel 10 everySecond Method doesn't work as expected

75 views Asked by At

According to laravel 10 documentation, we can use other sub-minute time constraints (everySecond, everyTwoSeconds, etc) for intervals lesser than one minute; but none of the sub-minute seems to be working as expected.

I have a very simple scheduled job below (strategic test 1)

protected function schedule(Schedule $schedule): void { $schedule->job(new StrategicTest1)->everySecond(); }

And my StrategicTest1 class below:

`class StrategicTest1 implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

/**
 * Create a new job instance.
 */
public function __construct()
{
    //
}

/**
 * Execute the job.
 */
public function handle(): void
{
    $st = Stretegy::find(1);

    $st->comment1 = random_int(1, 400);
    $st->code = 'st testing'.random_int(1, 400);

    $st->save();

    //echo 'done cats testing';

}

}TheeveryMinute()method works fine; buteverySecond()oreveryTwoSeconds()doesn't work. Instead I receiveBadMethodCallExceptionerror: BadMethodCallException

Method Illuminate\Console\Scheduling\CallbackEvent::everyTwoSeconds does not exist.

at vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php:113 109▕ */ 110▕ public function __call($method, $parameters) 111▕ { 112▕ if (! static::hasMacro($method)) { ➜ 113▕ throw new BadMethodCallException(sprintf( 114▕ 'Method %s::%s does not exist.', static::class, $method 115▕ )); 116▕ } 117▕

i Bad Method Call: Did you mean Illuminate\Console\Scheduling\CallbackEvent::everyTwoHours() ?

1 app/Console/Kernel.php:33`

Am I missing anything?

0

There are 0 answers