https://github.com/webman-tech/crontab-task
webman crontab plus
https://github.com/webman-tech/crontab-task
crontab task webman
Last synced: 10 months ago
JSON representation
webman crontab plus
- Host: GitHub
- URL: https://github.com/webman-tech/crontab-task
- Owner: webman-tech
- Created: 2023-05-05T15:50:36.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-06-13T06:21:28.000Z (12 months ago)
- Last Synced: 2025-07-06T02:05:54.628Z (11 months ago)
- Topics: crontab, task, webman
- Language: PHP
- Homepage:
- Size: 49.8 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# webman-tech/crontab-task
本项目是从 [webman-tech/components-monorepo](https://github.com/orgs/webman-tech/components-monorepo) 自动 split 出来的,请勿直接修改
> 简介
让 `workerman/crontab` 在 webman 中更加便捷的使用
## 安装
```bash
composer require webman-tech/crontab-task
```
## 特点
- 基于 [workerman/crontab](https://www.workerman.net/doc/webman/components/crontab.html)
- 支持单进程单个定时任务,和单进程多定时任务快捷配置(解决webman默认的单进程下起多个定时任务阻塞的问题),见配置 [process.php](copy/config/plugin/process.php)
- 定时任务常规 log 支持(start/end/exception),见配置 [app.php](copy/config/plugin/app.php)
## 使用
1. 创建 Task
```php
addTask('task1', '*/1 * * * * *', \WebmanTech\CrontabTask\Tasks\SampleTask::class)
// 添加多个定时任务,在同个进程中(注意会存在阻塞)
->addTasks('task2', [
['*/1 * * * * *', \WebmanTech\CrontabTask\Tasks\SampleTask::class],
['*/1 * * * * *', \WebmanTech\CrontabTask\Tasks\SampleTask::class],
])
->buildProcesses();
```
## 命令
`php webman crontab-task:list`: 列出所有 crontab 定时任务
`php webman make:crontab-task [name]`: 创建 crontab task