sam*_*toh 3 php cron scheduling laravel laravel-5.3
我通过像这样编辑 app\Console\Kernel.php 在 laravel 5.3 上创建了一个 cron 作业:
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use DB;
class Kernel extends ConsoleKernel
{
protected $commands = [
//
];
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
$id = 1;
DB::table('orders')
->where('id', $id)
->update(['status ' => 2, 'canceled_at' => date("Y-m-d H:i:s")]);
})->everyMinute();
}
protected function commands()
{
require base_path('routes/console.php');
}
}
Run Code Online (Sandbox Code Playgroud)
我试图检查数据库中的表,但它没有更新
如何测试我的 cron 工作?
小智 5
进入项目目录并运行
php /path/to/artisan schedule:run
Run Code Online (Sandbox Code Playgroud)
更多信息:https : //laravel.com/docs/5.3/scheduling
归档时间: |
|
查看次数: |
13463 次 |
最近记录: |