PHPackages                             bingher/think-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. [HTTP &amp; Networking](/categories/http)
4. /
5. bingher/think-crontab

ActiveLibrary[HTTP &amp; Networking](/categories/http)

bingher/think-crontab
=====================

ThinkPHP接口化定时任务管理

v0.4.2(3mo ago)014Apache-2.0PHPPHP &gt;=7.0.0

Since Jan 8Pushed 3mo agoCompare

[ Source](https://github.com/hbh112233abc/http-crontab)[ Packagist](https://packagist.org/packages/bingher/think-crontab)[ RSS](/packages/bingher-think-crontab/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (7)Versions (9)Used By (0)

ThinkCrontab接口化秒级定时任务
=====================

[](#thinkcrontab接口化秒级定时任务)

概述
--

[](#概述)

**项目来源**: [HttpCrontab](https://github.com/cshaptx4869/http-crontab)

基于 **Workerman** + **Sqlite** 的接口化秒级定时任务管理，兼容 Windows 和 Linux 系统。

> 主要改造点:

- 加入Service配置
- 数据库使用独立的Sqlite数据库
- 安装扩展自动加入配置文件crontab
- 仅作为ThinkPHP&gt;=8的扩展

定时器格式说明
-------

[](#定时器格式说明)

```
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位,则最小时间粒度是分钟]

```

使用
--

[](#使用)

### 启动服务

[](#启动服务)

```
php think crontab start
```

### 访问管理页面

[](#访问管理页面)

在配置文件中设置 `enable_http => true` 后，启动服务后即可通过浏览器访问配置的 `base_uri` 地址打开前端管理页面。例如：

- 默认配置: `http://127.0.0.1:2345`
- 自定义配置: `http://0.0.0.0:8080`

**注意**: 如需禁用 HTTP 服务和前端管理页面，设置 `enable_http => false` 即可，服务将仅运行定时任务。

帮助
--

[](#帮助)

```
$ php think crontab -h
Usage:
  crontab [options] [--]

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
```

配置
--

[](#配置)

### 数据库支持

[](#数据库支持)

本项目支持多种数据库类型，可根据项目需求选择合适的数据库：

数据库类型说明推荐场景sqlite轻量级文件数据库，无需额外安装开发环境、小型项目mysql开源关系数据库生产环境、中小型项目pgsqlPostgreSQL 开源关系数据库生产环境、高并发项目dm达梦数据库国产化适配、政府企业项目gauss高斯数据库国产化适配、企业级项目opengaussopenGauss 开源关系数据库国产化适配、开源项目**注意**: 不同数据库的 SQL 语法略有差异，系统会根据配置的 `database.type` 自动加载对应的建表 SQL。

配置文件位于 `config/crontab.php`，默认配置如下：

```
