PHPackages                             lizhibin/php-crond - 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. lizhibin/php-crond

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

lizhibin/php-crond
==================

php-crond

v1.0.9-stable(5y ago)3223[2 PRs](https://github.com/lizhibin205/php_crond/pulls)PHP &gt;=7.2.5

Since Oct 2Compare

[ Source](https://github.com/lizhibin205/php_crond)[ Packagist](https://packagist.org/packages/lizhibin/php-crond)[ RSS](/packages/lizhibin-php-crond/feed)WikiDiscussions Synced 2w ago

READMEChangelogDependencies (5)Versions (15)Used By (0)

php\_crond
==========

[](#php_crond)

[![Latest Stable Version](https://camo.githubusercontent.com/9a7559a09cc2ee4882e4d8e4686fef112ecda29b644769dd400270fa7cc587a6/68747470733a2f2f706f7365722e707567782e6f72672f6c697a686962696e2f7068702d63726f6e642f76657273696f6e)](https://packagist.org/packages/lizhibin/php-crond)[![Total Downloads](https://camo.githubusercontent.com/723c69eaf629934413dc1c0d27fde056ebb98cb885d18704542e84f1d8a68f2a/68747470733a2f2f706f7365722e707567782e6f72672f6c697a686962696e2f7068702d63726f6e642f646f776e6c6f616473)](https://packagist.org/packages/lizhibin/php-crond)[![Latest Unstable Version](https://camo.githubusercontent.com/342b79a3ca2ec05f00c76bce716537396ad76099415e98f625eed9dd92b84f8c/68747470733a2f2f706f7365722e707567782e6f72672f6c697a686962696e2f7068702d63726f6e642f762f756e737461626c65)](//packagist.org/packages/lizhibin/php-crond)[![License](https://camo.githubusercontent.com/9ef1dace0ed47de4450e35336b6efeb2ed5ff3d2c77f725a158e70c0bcde7c6e/68747470733a2f2f706f7365722e707567782e6f72672f6c697a686962696e2f7068702d63726f6e642f6c6963656e7365)](https://packagist.org/packages/lizhibin/php-crond)

基于多进程的定时任务管理器，支持秒级别的定时任务

特性
--

[](#特性)

- 通过配置文件管理所有定时任务
- 支持秒级的定时任务粒度
- 使用symfony/process进行进程管理
- 使用React/event-loop执行事件循环
- 提供http服务，远程查看和操作php\_crond（[参见：API文档](https://github.com/lizhibin205/php_crond/wiki/API%E6%8E%A5%E5%8F%A3%E6%96%87%E6%A1%A3)）

执行
--

[](#执行)

启动crond

```
php bin/crond.php
```

在后台启动crond

```
nohup php bin/crond.php > /dev/null 2>&1 &
```

发送USR1信号，安全关闭crond 主进程会等待所有的子进程任务结束，才会正式退出

```
kill -USR1 `cat logs/crond.pid`
```

发送USR2信号，重新读取task配置文件

```
kill -USR2 `cat logs/crond.pid`
```

基本配置
----

[](#基本配置)

服务配置文件config/base.php

```
return [
    //模式
    'model' => 'daemon',
    //PHP程序路径
    'php' => '/usr/local/php-5.6.30/bin/php',
    //日志文件
    'log_file' => PROJECT_ROOT . "/logs/crond.log",
    //主进程pid文件
    'pid_file' => PROJECT_ROOT . "/logs/crond.pid",
    //http接口服务，提供接口远程操作php_crond
    'http_server' => [
        'switch' => false,//是否启动http服务
        'listen' => '127.0.0.1',
        'port' => 8080,//监听端口
    ],
];
```

任务配置
----

[](#任务配置)

任务配置文件config/task.php

```
/**
 * task配置文件
 * 例子：
 */
return ['demo' => [
  'daemon' => '* * * * * *',//秒 分 时 日 月 周
  'filename' => 'sleep', //执行程序
  'params' => ['5'],//执行程序参数
  'single' => true,//如果进程在运行，则不执行，只保持一个进程
  'standard_ouput' => '/dev/null', //标准输出
  'error_output' => '/dev/null', // 错误输出
]];
```

如果你需要配置非常多的任务，可以使用Storage\\Reader::registerTaskDirectory，该方法会遍历注册目录下的所有.php文件，并返回其中的任务列表

```
return \Storage\Reader::registerTaskDirectory(__DIR__ . "/tasks");
```

允许配置外部接口，用于返回任务列表。参数url=接口地址，serverId=作为服务标识

PS：你可能需要额外搭建后台用于任务管理

```
return \Storage\Reader::registerTaskRemote($url, $serverId);
```

接口返回例子

```
{
    "demo": {
        "daemon": "0 * * * * *",
        "filename": "echo",
        "params": ["hello world!"],
        "single": true,
        "standard_ouput": "/dev/null",
        "error_output": "/dev/null"
    }
}
```

安全配置
----

[](#安全配置)

任务配置文件config/security.php

```
use Storage\Security\FixedCommandRule;

return [
    //固定命令
    new FixedCommandRule("sleep"),
];
```

###  Health Score

31

—

LowBetter than 65% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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 ~112 days

Total

11

Last Release

2118d ago

PHP version history (3 changes)v1.0.2-stablePHP &gt;=5.5.9

v1.0.6.x-devPHP &gt;=5.6.0

v1.0.9.x-devPHP &gt;=7.2.5

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13945851?v=4)[zhibin](/maintainers/lizhibin205)[@lizhibin205](https://github.com/lizhibin205)

---

Top Contributors

[![lizhibin205](https://avatars.githubusercontent.com/u/13945851?v=4)](https://github.com/lizhibin205 "lizhibin205 (80 commits)")

### Embed Badge

![Health badge](/badges/lizhibin-php-crond/health.svg)

```
[![Health](https://phpackages.com/badges/lizhibin-php-crond/health.svg)](https://phpackages.com/packages/lizhibin-php-crond)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.9k556.2M21.3k](/packages/laravel-framework)[tempest/framework

The PHP framework that gets out of your way.

2.3k37.6k20](/packages/tempest-framework)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k39.6k](/packages/matomo-matomo)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.9M534](/packages/pimcore-pimcore)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.8M668](/packages/shopware-core)

PHPackages © 2026

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