首页 > 解决方案 > 检查下一个运行 Laravel 的时间表是什么时候

问题描述

有什么方法可以查看下一个schedule命令何时运行?

例子:

$schedule->command("update:example")->dailyAt('07:00')->withoutOverlapping();

现在是2020-09-23 08:00:00,计划运行的下一个时间戳应该是2020-09-24 07:00:00.

有办法2020-09-24 07:00:00在它真正发生之前得到它吗?


我刚刚找到有关日志的文章,这不是我想要的。

标签: laravel

解决方案


您可以获得所有任务并通过它们来找到您需要的内容

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Support\Str;

$schedule = app(Schedule::class);

$tasks = collect($schedule->events());

$matches = $tasks->filter(function ($item) {
    return Str::contains($item->command, 'update:example');
});

// assuming you get something back in that collection

$matches->first()->nextRunDate();

你应该得到一些你需要的碳对象。

希望对您有所帮助。


推荐阅读