1

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?

1 Answer 1

0

The Sub-minute Scheduling was implemented starting version 10.15 ( https://laravelversions.com/en/10#10.15.0). Maybe, your Laravel version is below the 10.15.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.