dongmie3987067 2019-05-01 11:29
浏览 93

Laravel Cron Job在Windows 10中只运行一次

I've created a Task Scheduling from Laravel Documentation: https://laravel.com/docs/5.7/scheduling

I put it everyMinute() and it only execute once when I use that command and not executing every minute. I used cronhub.io to monitor it and the result was the one I execute the command.

enter image description here

This is the command I execute:

$ 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");
    }

And on my 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();
    }
}

Does it only run once in windows 10? cause this is my first time using cron jobs.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器