cshaptx4869 / http-crontab
接口化定时任务管理
Installs: 1 130
Dependents: 0
Suggesters: 0
Security: 0
Stars: 10
Watchers: 1
Forks: 3
Open Issues: 0
Requires
- php: >=7.0.0
- ext-json: *
- nikic/fast-route: ^1.3
- workerman/crontab: ^1.0
- workerman/mysql: ^1.0
- workerman/workerman: ^4.0
This package is auto-updated.
Last update: 2024-11-07 07:15:52 UTC
README
概述
基于 Workerman + MySQL 的接口化秒级定时任务管理,兼容 Windows 和 Linux 系统。
定时器格式说明
0 1 2 3 4 5
| | | | | |
| | | | | +------ day of week (0 - 6) (Sunday=0)
| | | | +------ month (1 - 12)
| | | +-------- day of month (1 - 31)
| | +---------- hour (0 - 23)
| +------------ min (0 - 59)
+-------------- sec (0-59)[可省略,如果没有0位,则最小时间粒度是分钟]
简单使用
- 新建 run.php
<?php require_once "./vendor/autoload.php"; use Fairy\HttpCrontab; date_default_timezone_set('PRC'); //数据库配置 //启动脚本后会自行创建所需的数据表 //定时器任务执行日志按月自动分表 $dbConfig = [ 'hostname' => '127.0.0.1', 'hostport' => '3306', 'username' => 'root', 'password' => 'root', 'database' => 'test', 'charset' => 'utf8mb4' ]; //启动后默认监听 http://127.0.0.1:2345 //可在new的时候传递第一个参数改变监听地址 (new HttpCrontab())->setDebug(true) ->setName('System Crontab') ->setDbConfig($dbConfig) ->run();
- 启动服务
集成项目
easyadmin 是基于 ThinkPHP6.1 和 Layui2.7 的快速开发的后台管理系统。
- 启动服务
$ php think crontab -h Usage: crontab [options] [--] <action> Arguments: action start|stop|restart|reload|status|connections Options: -d, --daemon Run the http crontab server in daemon mode. --name[=NAME] Crontab name [default: "Crontab Server"] --debug Print log -h, --help Display this help message -V, --version Display this console version -q, --quiet Do not output any message --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
- UI操作界面
定时器接口说明
PING
基本信息
Path: /crontab/ping
Method: GET
接口描述:
{
"code": 200,
"data": "pong",
"msg": "信息调用成功!"
}
请求参数
返回数据
修改
基本信息
Path: /crontab/modify
Method: POST
接口描述:
{
"code": 200,
"data": true,
"msg": "信息调用成功!"
}
请求参数
Headers
Body
返回数据
列表
基本信息
Path: /crontab/index
Method: GET
接口描述:
{
"code": 200,
"data": {
"list": [
{
"id": 1,
"title": "输出 tp 版本",
"type": 0,
"frequency": "*/3 * * * * *",
"shell": "php think version",
"running_times": 3,
"last_running_time": 1625636646,
"remark": "没3秒执行",
"sort": 0,
"status": 1,
"create_time": 1625636609,
"update_time": 1625636609
}
],
"count": 1
},
"msg": "信息调用成功!"
}
请求参数
Query
返回数据
删除
基本信息
Path: /crontab/delete
Method: POST
接口描述:
{
"code": 200,
"data": true,
"msg": "信息调用成功!"
}
请求参数
Headers
Body
返回数据
定时器池
基本信息
Path: /crontab/pool
Method: GET
接口描述:
{
"code": 200,
"data": [
{
"id": 1,
"shell": "php think version",
"frequency": "*/3 * * * * *",
"remark": "没3秒执行",
"create_time": "2021-07-07 13:43:29"
}
],
"msg": "信息调用成功!"
}
请求参数
返回数据
日志
基本信息
Path: /crontab/flow
Method: GET
接口描述:
{
"code": 200,
"data": {
"list": [
{
"id": 12,
"sid": 1,
"command": "php think version",
"output": "v6.0.7",
"return_var": 0,
"running_time": "0.115895",
"create_time": 1625636673,
"update_time": 1625636673
},
{
"id": 11,
"sid": 1,
"command": "php think version",
"output": "v6.0.7",
"return_var": 0,
"running_time": "0.104641",
"create_time": 1625636670,
"update_time": 1625636670
},
{
"id": 10,
"sid": 1,
"command": "php think version",
"output": "v6.0.7",
"return_var": 0,
"running_time": "0.106585",
"create_time": 1625636667,
"update_time": 1625636667
},
{
"id": 9,
"sid": 1,
"command": "php think version",
"output": "v6.0.7",
"return_var": 0,
"running_time": "0.10808",
"create_time": 1625636664,
"update_time": 1625636664
},
{
"id": 8,
"sid": 1,
"command": "php think version",
"output": "v6.0.7",
"return_var": 0,
"running_time": "0.107653",
"create_time": 1625636661,
"update_time": 1625636661
},
{
"id": 7,
"sid": 1,
"command": "php think version",
"output": "v6.0.7",
"return_var": 0,
"running_time": "0.105938",
"create_time": 1625636658,
"update_time": 1625636658
},
{
"id": 6,
"sid": 1,
"command": "php think version",
"output": "v6.0.7",
"return_var": 0,
"running_time": "0.10461",
"create_time": 1625636655,
"update_time": 1625636655
},
{
"id": 5,
"sid": 1,
"command": "php think version",
"output": "v6.0.7",
"return_var": 0,
"running_time": "0.109786",
"create_time": 1625636652,
"update_time": 1625636652
},
{
"id": 4,
"sid": 1,
"command": "php think version",
"output": "v6.0.7",
"return_var": 0,
"running_time": "0.115853",
"create_time": 1625636649,
"update_time": 1625636649
},
{
"id": 3,
"sid": 1,
"command": "php think version",
"output": "v6.0.7",
"return_var": 0,
"running_time": "0.16941",
"create_time": 1625636646,
"update_time": 1625636646
},
{
"id": 2,
"sid": 1,
"command": "php think version",
"output": "v6.0.7",
"return_var": 0,
"running_time": "0.109524",
"create_time": 1625636643,
"update_time": 1625636643
},
{
"id": 1,
"sid": 1,
"command": "php think version",
"output": "v6.0.7",
"return_var": 0,
"running_time": "0.108445",
"create_time": 1625636640,
"update_time": 1625636640
}
],
"count": 12
},
"msg": "信息调用成功!"
}
请求参数
Query
返回数据
添加
基本信息
Path: /crontab/add
Method: POST
接口描述:
{
"code": 200,
"data": true,
"msg": "信息调用成功!"
}
请求参数
Headers
Body
返回数据
重启
基本信息
Path: /crontab/reload
Method: POST
接口描述:
{
"code": 200,
"data": true,
"msg": "信息调用成功!"
}
请求参数
Headers
Body
返回数据