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

ActiveThink-extend[Utility &amp; Helpers](/categories/utility)

xieyongfa/think-crontab
=======================

The ThinkPHP5.1.\* Crontab Package

v1.0.0(7y ago)4391[1 issues](https://github.com/xieyongfa123/think-crontab/issues)Apache-2.0PHPPHP &gt;=7.1

Since Nov 8Pushed 7y ago1 watchersCompare

[ Source](https://github.com/xieyongfa123/think-crontab)[ Packagist](https://packagist.org/packages/xieyongfa/think-crontab)[ RSS](/packages/xieyongfa-think-crontab/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

think-crontab for ThinkPHP5.1.\*
================================

[](#think-crontab-for-thinkphp51)

安装
--

[](#安装)

> composer require xieyongfa/think-crontab

开始使用
----

[](#开始使用)

> 创建如下数据表

```
CREATE TABLE `crontab`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '任务名',
  `class` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '类名',
  `payload` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL NOT NULL COMMENT '参数',
  `last_execute_time` datetime(0) NOT NULL COMMENT '上次执行时间',
  `next_execute_time` datetime(0) NOT NULL COMMENT '下次执行时间',
  `status` tinyint(2) NOT NULL DEFAULT 1 COMMENT '0禁用 1启用',
  `interval_sec` int(11) NOT NULL DEFAULT 60 COMMENT '执行间隔 单位秒',
  `create_time` datetime(0) NOT NULL COMMENT '创建时间',
  `update_time` datetime(0) NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

```

创建计划任务
------

[](#创建计划任务)

> `push_crontab($name, $class, $payload = [], $interval_sec = 60)`

`$name` 是任务名

`$class` 是类名

`$payload` 是参数 数组格式

`$interval_sec` 是任务执行周期 默认60秒

### 创建计划任务例子

[](#创建计划任务例子)

```
$payload = ['name' => 'thinkphp'];
push_crontab('test', 'app\\test\\controller\\echo_date', $payload, 60);

```

监听计划并执行,强烈建议配合supervisor使用，保证进程常驻
---------------------------------

[](#监听计划并执行强烈建议配合supervisor使用保证进程常驻)

> php think crontab --sleep=60 --memory=8

sleep参数:间隔多久查询一次 单位秒 memory参数:单个进程消耗内存超过多少M自动退出(配合supervisor可达到自动重启效果,防止内存溢出)

开发帮助及交流
-------

[](#开发帮助及交流)

- **作者QQ：2392523899**
- **开发交流QQ群：453142313（新）**

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

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

2739d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e553464d602d87df2ea47e50e9c8d5f20cf7865f476e1796fe89302aa47af0bc?d=identicon)[xieyongfa123](/maintainers/xieyongfa123)

---

Top Contributors

[![xieyongfa123](https://avatars.githubusercontent.com/u/15604264?v=4)](https://github.com/xieyongfa123 "xieyongfa123 (5 commits)")

### Embed Badge

![Health badge](/badges/xieyongfa-think-crontab/health.svg)

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

PHPackages © 2026

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