P
P
Pavel2020-06-29 18:34:21
Laravel
Pavel, 2020-06-29 18:34:21

Why does CRON-schedule:run execute a command once?

Can't get command to run every minute

class Kernel extends ConsoleKernel
{
    protected $commands = [
        'App\Console\Commands\CheckSite',
    ];

    protected function schedule(Schedule $schedule)
    {
        $schedule->command('check:site')->everyMinute();
    }

and the command itself:
namespace App\Console\Commands;

use Illuminate\Console\Command;

class CheckSite extends Command
{
    protected $signature = 'check:site';

    protected $description = 'The console command description.';

    public function __construct()
    {
        parent::__construct();
    }

    public function handle()
    {
       // dd('test');
        Log:info('чек сайт');
    }
}

at startup, the php artisan schedule:run

team works out once and finish, does not want to continue

Tell me where is the error?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin B., 2020-06-29
@Kostik_1993

Tell me where is the mistake?
If you would just for a second think about what you write. This command that you write is one-time. In order for it to run every minute, you must run it every minute in the console. But since you won't be able to do this on the production site, you need to run this command via cron. The documentation has everything for this. But what is cron you first need to learn

S
segio_tt, 2020-07-02
@art055

https://github.com/spatie/laravel-cronless-schedule
I will only add such a library for the author who does not want to specify a command on the server so that it is always executed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question