我正在使用windows。爲什麼我的cron job laravel 5.3不能在localhost上工作?
我對\app\Console\Kernel.php
代碼是這樣的:
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
protected $commands = [
Commands\CustomCommand::class,
];
protected function schedule(Schedule $schedule)
{
$schedule->command('custom:command')
->everyMinute();
}
protected function commands()
{
require base_path('routes/console.php');
}
}
我對\app\Console\Commands\CustomCommand.php
代碼是這樣的:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use DB;
class CustomCommand extends Command
{
protected $signature = 'custom:command';
protected $description = 'test cron job to update status on table order';
public function __construct()
{
parent::__construct();
}
public function handle()
{
$id = 1;
DB::table('orders')
->where('id', $id)
->update(['status' => 2, 'canceled_at' => date("Y-m-d H:i:s")]);
}
}
我跑php artisan list
看到我的cron作業
找到我的cron後作業(自定義:命令),然後我像這樣運行我的cron作業:php artisan custom:command
它成功更新狀態= 2.之後,我手動將狀態更改爲1,然後等待一分鐘,它不再更新狀態
有沒有人可以幫助我?