0

I'm trying to make scheduled task for every 5 seconds.

This is my code.

  */
    protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')
        //          ->hourly();

        $schedule->call('App\Http\Controllers\SoapController@show')->cron('0,5 * * * *');


    }

    /**
     * Register the Closure based commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        require base_path('routes/console.php');
    }

And I'm getting this error when I enter

php artisan schedule:run

command.

No scheduled commands are ready to run.

Edit:

I Updated my scheduler and command section. I created a command.

And when I use it like

php artisan get:data

its working.

But when I try it with scheduler its just working for 1 time.

protected $commands = [
        \App\Console\Commands\GetData::class,
    ];


 $schedule->command('get:data')->cron('* * * * *');
Murat Kaya
  • 1,281
  • 3
  • 28
  • 52

1 Answers1

1

You can't specify a scheduled task to run every n seconds. The system relies on a crontab task and these can only scheduled to the minute and no smaller unit. This is why it's not possible to define a scheduled task to run every n seconds, even with the cron method (since seconds aren't supported by cron).

edcs
  • 3,847
  • 2
  • 33
  • 56