首页 > 解决方案 > Laravel 任务计划程序只运行一次命令

问题描述

嗨,我知道有类似的主题,但我的问题是关于本地服务器(windows artisan 服务器)当我运行 php artisan schedule:run 电子邮件通知仅第一次运行时,调度程序在本地或共享服务器上都不起作用。

MinuteUpdate.php

    public function handle()
    {

        $users = User::all();

        foreach ($users as $user) {
           
                Mail::to($user->email)->send(new CrendentialsNotify($user->name,$user->email,$user->plate));
                $this->info('Minute Update');
         
        }
    }

内核.php


 <?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        
        Commands\MinuteUpdate::class
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('minute:update')->everyMinute();
   
   
        // $schedule->command('check:reserve')->everyMinute();

    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}

标签: phplaravel

解决方案


推荐阅读