visavi/crontask
Composer 安装命令:
composer require visavi/crontask
包简介
Simple PHP cron tasks
关键字:
README 文档
README
Introduction
This package contains a simple PHP cron task scheduler that helps you version control your cron jobs.
Requirements
This library package requires PHP 7.0 or later
Installation
Installing via Composer
The recommended way to install crontask is through Composer.
Next, run the Composer command to install the latest version of crontask:
composer require visavi/crontask
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
Once you've created your task list script (see Usage below) open a linux shell add the following line to crontab (crontab -e):
* * * * * php /path/cron.php
Usage
The following example shows how to schedule a HelloDaily task (simple echo example) and a ShellMonday task (running a shell task example).
class HelloDailyTask extends \Crontask\Tasks\Task { public function run() { $this->setOutput('Hello World'); } } class ShellMondayTask extends \Crontask\Tasks\Shell { protected $command = "echo Hello Monday"; } $taskList = new \Crontask\TaskList(); // Add task to run at 12:00 every day $taskList->addTask((new HelloDailyTask)->setExpression('12 0 * * *')); // Add task to run every hour $taskList->addTask((new HelloDailyTask)->setExpression('@hourly')); // Add task to run at 12:00 every Monday $taskList->addTask((new ShellMondayTask)->setExpression('12 0 * * 1')); // or $taskList->addTasks([ (new HelloDailyTask)->setExpression('12 0 * * 1'), (new HelloDailyTask)->setExpression('@hourly'), (new ShellMondayTask)->setExpression('12 0 * * 1'), ]); $taskList->run();
CRON Expressions
A CRON expression is a string representing the schedule for a particular command to execute. The parts of a CRON schedule are as follows:
* * * * *
- - - - -
| | | | |
| | | | |
| | | | +----- day of week (0 - 7) (Sunday=0 or 7)
| | | +---------- month (1 - 12)
| | +--------------- day of month (1 - 31)
| +-------------------- hour (0 - 23)
+------------------------- min (0 - 59)
Mappings
@yearly => 0 0 1 1 *
@annually => 0 0 1 1 *
@monthly => 0 0 1 * *
@weekly => 0 0 * * 0
@daily => 0 0 * * *
@hourly => 0 * * * *
License
The class is open-sourced software licensed under the MIT license
visavi/crontask 适用场景与选型建议
visavi/crontask 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18.43k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2017 年 10 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「cron」 「task」 「crontab」 「scheduler」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 visavi/crontask 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 visavi/crontask 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 visavi/crontask 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Symfony bundle to monitor and execute commands
Expose the DDev executable commands to the Robo task runner.
Scheduling extension for Yii2 framework
Monitoring for scheduled jobs
Temporal frequency library
Task system for APPUI
统计信息
- 总下载量: 18.43k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 24
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-10-20