PHPackages                             weijukeji/laravel-schedule-monitor-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. weijukeji/laravel-schedule-monitor-api

ActiveLibrary[API Development](/categories/api)

weijukeji/laravel-schedule-monitor-api
======================================

REST API endpoints for spatie/laravel-schedule-monitor - expose scheduled task status and logs

v1.0.0(2w ago)04MITPHPPHP ^8.3

Since Mar 6Pushed 2w agoCompare

[ Source](https://github.com/WeiJuKeJi/laravel-schedule-monitor-api)[ Packagist](https://packagist.org/packages/weijukeji/laravel-schedule-monitor-api)[ RSS](/packages/weijukeji-laravel-schedule-monitor-api/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (6)Versions (2)Used By (0)

Laravel Schedule Monitor API
============================

[](#laravel-schedule-monitor-api)

为 [spatie/laravel-schedule-monitor](https://github.com/spatie/laravel-schedule-monitor) 提供 REST API 接口，将定时任务的监控状态和执行日志以 JSON 格式暴露出来，方便前端或其他服务消费。

依赖
--

[](#依赖)

- PHP &gt;= 8.3
- Laravel &gt;= 12.0
- [spatie/laravel-schedule-monitor](https://github.com/spatie/laravel-schedule-monitor) ^4.0

安装
--

[](#安装)

```
composer require weijukeji/laravel-schedule-monitor-api
```

发布配置文件（可选）：

```
php artisan vendor:publish --tag=schedule-monitor-api-config
```

配置
--

[](#配置)

配置文件位于 `config/schedule-monitor-api.php`：

```
return [
    // API 路由前缀
    'route_prefix' => 'api/v1/system/schedule-tasks',

    // 路由名称前缀
    'route_name' => 'system.schedule-tasks',

    // 路由中间件
    'middleware' => ['auth:sanctum'],

    // 任务列表每页数量
    'per_page' => 20,

    // 日志列表每页数量
    'log_per_page' => 50,
];
```

API 接口
------

[](#api-接口)

### 获取任务列表

[](#获取任务列表)

```
GET /api/v1/system/schedule-tasks

```

**查询参数：**

参数类型说明`page`int页码，默认 1`per_page`int每页数量，默认 20`status`string按状态筛选，见下方状态说明**响应示例：**

```
{
    "code": 200,
    "msg": "success",
    "data": {
        "list": [
            {
                "id": 1,
                "name": "同步订单数据",
                "type": "command",
                "cron_expression": "0 * * * *",
                "timezone": "Asia/Shanghai",
                "grace_time_in_minutes": 5,
                "status": "healthy",
                "last_started_at": "2026-03-06 09:00:00",
                "last_finished_at": "2026-03-06 09:00:01",
                "last_failed_at": null,
                "last_skipped_at": null,
                "created_at": "2026-01-01 00:00:00",
                "updated_at": "2026-03-06 09:00:01"
            }
        ],
        "total": 1
    }
}
```

---

### 获取任务日志

[](#获取任务日志)

```
GET /api/v1/system/schedule-tasks/{id}/logs

```

**路径参数：**

参数类型说明`id`int任务 ID**查询参数：**

参数类型说明`page`int页码，默认 1`per_page`int每页数量，默认 50**响应示例：**

```
{
    "code": 200,
    "msg": "success",
    "data": {
        "task": { ... },
        "list": [
            {
                "id": 100,
                "type": "finished",
                "meta": [],
                "created_at": "2026-03-06 09:00:01"
            }
        ],
        "total": 100
    }
}
```

---

任务状态说明
------

[](#任务状态说明)

状态由 `TaskStatusResolver` 按优先级依次判断：

状态值说明从未运行`never_ran`任务自创建以来从未执行过失败`failed`最近一次执行失败，且之后未成功完成警告`warning`任务已超过预期执行时间 + 宽限期仍未完成健康`healthy`任务按时正常完成**`warning` 判断逻辑：**

基于 cron 表达式推算出下次应执行时间，加上宽限期后仍未完成则标记为警告，而不是简单以上次完成时间为基准。

```
下次预期执行时间（by cron）+ grace_time_in_minutes < 现在 → warning

```

日志类型说明
------

[](#日志类型说明)

类型说明`starting`任务开始执行`finished`任务成功完成`failed`任务执行失败`skipped`任务被跳过日志自动清理
------

[](#日志自动清理)

`spatie/laravel-schedule-monitor` 的日志模型使用了 Laravel `MassPrunable`，默认保留 **30 天**。

可在业务项目的 `config/schedule-monitor.php` 中修改保留天数：

```
'delete_log_items_older_than_days' => 30,
```

需要在定时任务中注册清理命令，否则日志不会自动清除：

```
// routes/console.php 或 app/Console/Kernel.php
Schedule::command('model:prune')->daily();
```

License
-------

[](#license)

MIT

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance97

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

16d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/27f8944998bade02e78cf1fa70a4363be1960fe9d6fb86b0837bf1b4e7de93b1?d=identicon)[ruihuachen](/maintainers/ruihuachen)

---

Top Contributors

[![ChenRuihua](https://avatars.githubusercontent.com/u/46486133?v=4)](https://github.com/ChenRuihua "ChenRuihua (1 commits)")

---

Tags

apilaravelcronschedulemonitor

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/weijukeji-laravel-schedule-monitor-api/health.svg)

```
[![Health](https://phpackages.com/badges/weijukeji-laravel-schedule-monitor-api/health.svg)](https://phpackages.com/packages/weijukeji-laravel-schedule-monitor-api)
```

###  Alternatives

[mtownsend/response-xml

The missing XML support for Laravel's Response class.

1071.2M2](/packages/mtownsend-response-xml)[missael-anda/laravel-whatsapp

A Whatsapp Business Cloud API wrapper for Laravel.

677.2k](/packages/missael-anda-laravel-whatsapp)[hcesrl/laravel-swagger-api

API Swagger UI package for Laravel.

695.6k](/packages/hcesrl-laravel-swagger-api)[lisennk/laravel-slack-events-api

Slack Events API for Laravel 5, 6, 7 and 8

3911.3k](/packages/lisennk-laravel-slack-events-api)[shahghasiadil/laravel-api-versioning

Elegant attribute-based API versioning solution for Laravel applications with built-in deprecation management and version inheritance

2912.6k](/packages/shahghasiadil-laravel-api-versioning)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
