Laravel Cron Job Run только один раз в Windows 10 - PullRequest
0 голосов
/ 01 мая 2019

Я создал расписание задач из документации Laravel: https://laravel.com/docs/5.7/scheduling

Я ставлю его everyMinute (), и он выполняется только один раз, когда я использую эту команду, а не выполняю каждую минуту. Я использовал cronhub.io для мониторинга, и в результате я выполнил команду.

enter image description here

Это команда, которую я выполняю:

$ php artisan schedule:run
Running scheduled command: "E:\Laragon\bin\php\php-7.2.11-Win32-VC15-x64\php.exe" "artisan" update:weather > "NUL" 2>&1

App \ Console \ Kernel.php

<?php
...
class Kernel extends ConsoleKernel
{
...
protected function schedule(Schedule $schedule)
    {          $schedule->command('update:weather')->everyMinute()->thenPing("https://cronhub.io/ping/ce3d19a0-6c01-11e9-8ce3-9b563ae1be45");
    }

И на моем App \ Console \ Commands \ UpdateWeatherIcon.php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Enums\WeatherIcon;
use App\Weather;

class UpdateWeatherIcon extends Command
{
    protected $signature = 'update:weather';
    protected $description = 'Update Weather Icon every end of day';

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

    public function handle()
    {
        $weather = new WeatherIcon();

        $current_weather = Weather::find(1);
        $current_weather->current_weather = $weather->getRandomValue();
        $current_weather->updated_at = \Carbon\Carbon::now();
        $current_weather->save();
    }
}

Он запускается только один раз в Windows 10? потому что я впервые использую задания cron.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...