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 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?