PHPackages                             yzh52521/swoole-crontab - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. yzh52521/swoole-crontab

ActivePackage[Utility &amp; Helpers](/categories/utility)

yzh52521/swoole-crontab
=======================

基于 swoole 的定时任务服务

v1.0.1(2y ago)17Apache-2.0PHPPHP &gt;=7.1

Since Jun 13Pushed 2y ago1 watchersCompare

[ Source](https://github.com/yzh52521/swoole-crontab)[ Packagist](https://packagist.org/packages/yzh52521/swoole-crontab)[ RSS](/packages/yzh52521-swoole-crontab/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

yzh52521/swoole-crontab
=======================

[](#yzh52521swoole-crontab)

简介
--

[](#简介)

`yzh52521/swoole-crontab`是基于`swoole`的定时任务服务,

安装说明
----

[](#安装说明)

- 详见 `composer.json` `require`

运行说明
----

[](#运行说明)

- 启动`server`时,添加用户进程`Process`加载`data_file`配置文件到`Swool\Table`中,`worker`进程接收请求,用户进程每分钟扫描一次`Swool\Table`解析定时任务.创建|删除|启动|关闭定时任务请求会实时更新`data_file`配置文件内容,并且修改`Swool\Table`内容.
- 默认`Swool\Table`大小为1024行,最多添加1024个定时任务.
- 复制项目根目录`test`文件中`Crontab.php`
- 服务启动默认配置为项目下`Config.php`
- 注意修改引入的`vendor/autoload.php`文件路径

```
php Crontab start #调试模式
php Crontab start -d #常驻内存模式
php Crontab stop #关闭常驻内存服务
```

请求说明
----

[](#请求说明)

- 运行后默认请求地址为: `baseUrl`(`http://ip:9501/`),请求响应格式统一为`json`
- 开启定时任务后可能不会立即执行,等待执行时间为0-60秒
- 请求方式统一为`post`,请求地址如下:
    - 创建任务:`baseUrl/create````
        // 请求字段
        {
            "name": "url",    // 任务名称
            "start_time": 0,  // 开始时间默认0解析format格式直接运行
            "end_time": 0,   // 结束时间默认0一直运行
            "format": "* * * * * *",  // 执行时间格式参见Crontab基本格式再加上一个秒
            "run_type": "Curl",  // 运行方式内置Class, Curl , Bash三种方式
            "command": "http://192.168.1.102"  // class 任务 "command": {"\app\task\Test","execute"}"
        }
        ##注释:bash运行方式必须配置白名单文件路径`bash_whitelist_file`,内容为可执行的`sh`脚本的绝对路径,保证服务器安全,详见`BashJobExecute`文件
        //返回字段
        {
            "code": 0,
            "message": "操作成功.",
            "data": {
                "id": "60457f0d17313" //任务编号
            }
        }
        ```
    - 任务列表:`baseUrl/all````
            {
                "code": 0,
                "message": "操作成功.",
                "data": {
                    "job_list": {
                        "604582ba74e34": {
                            "name": "Curl",
                            "start_time": 0,
                            "end_time": 0,
                            "format": "* * * * * *",
                            "run_type": "Curl",
                            "command": "http://192.168.1.102",
                            "status": 1
                        }
                    }
                }
            }
        ```
    - 以下接口需`post`创建任务时返回的任务编号(`id`)参数
        - 查找任务:`baseUrl/find`
        - 删除任务:`baseUrl/delete`
        - 任务统计:`baseUrl/count`
        - 开始任务:`baseUrl/start`
        - 停止任务:`baseUrl/stop`

返回格式
----

[](#返回格式)

```
{
    "code": 0, //响应码
    "message": "操作成功.",//响应说明
    "data": {} //非0无此字段
}
```

code响应码
-------

[](#code响应码)

- 0 成功
- 1 失败
- 405 访问Method错误,只允许post
- 404 url访问不存在
- 500 服务出错

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

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

Every ~5 days

Total

2

Last Release

1056d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/052aa4acd90ad5d672ae5abe8d27d1f576f9c07e1967e2f6bced03b84079310f?d=identicon)[yuanzhihai](/maintainers/yuanzhihai)

---

Top Contributors

[![yuanzhihai](https://avatars.githubusercontent.com/u/15060466?v=4)](https://github.com/yuanzhihai "yuanzhihai (11 commits)")

---

Tags

swoolecrontab

### Embed Badge

![Health badge](/badges/yzh52521-swoole-crontab/health.svg)

```
[![Health](https://phpackages.com/badges/yzh52521-swoole-crontab/health.svg)](https://phpackages.com/packages/yzh52521-swoole-crontab)
```

###  Alternatives

[ashallendesign/favicon-fetcher

A Laravel package for fetching website's favicons.

190272.4k3](/packages/ashallendesign-favicon-fetcher)[hyperf/crontab

A crontab component for Hyperf.

131.6M62](/packages/hyperf-crontab)[arrowjustdoit/crontab

Crontab extension for laravel-admin

334.0k](/packages/arrowjustdoit-crontab)

PHPackages © 2026

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