php - Laravel Cron Job 在 Windows 10 中只运行一次
问题描述
我从 Laravel 文档创建了一个任务调度:https ://laravel.com/docs/5.7/scheduling
我把它放在 everyMinute() 中,当我使用该命令时它只执行一次,而不是每分钟执行一次。我使用 cronhub.io 对其进行监控,结果是我执行命令的结果。
这是我执行的命令:
$ 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
应用\控制台\内核.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 作业。
解决方案
推荐阅读
- python - 如何在 django 管理中将日期层次结构限制为年?
- java - 如何将最新图像显示到 ImageView 另一个活动?
- python - 如何多次运行一个函数并返回不同的结果python
- sql - Left Join 在匹配数据上返回 NULL
- java - Object2ObjectOpenHashMap put 方法中的 Nullpointerexception
- rust - async_std::sync::Arc 的目的是什么?
- amazon-web-services - 在 S3 静态网站托管中返回错误文档时是否可以自定义 HTTP 状态代码
- ckeditor - CRM 中的 CKEditor - SCRIPT5011 错误“无法从已释放的脚本中执行代码”
- vue.js - 如文档中所示,Kendo vue 开关未显示?
- google-cloud-platform - GKE Connect 成功启动,但集群未显示在 GCP 控制台中