Download the PHP package uniondrug/crontab without Composer
On this page you can find all versions of the php package uniondrug/crontab. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package crontab
Crontab component for uniondrug/framework
定时任务工具
安装
修改 app.php
配置文件,注入服务。服务名称 crontabService
。
修改server.php
配置文件,启动两个进程:
配置
Crontab的配置文件是 crontab.php
, 主要有如下参数:
使用
Crontab 通过注解定义定时任务。需要定时运行的任务,需要在app/Tasks
中创建,并且继承 Uniondrug\Server\Task\TaskHandler
,举例如下:
注解说明:
- 注解名称
@Schedule
-
参数设置:
- cron 必填。Linux的Crontab格式定义。支持到分钟。
- second 可选。指定运行的秒。通过这个参数,可以精确到秒来运行任务。默认是 0。支持的格式包括:
- "*" 每秒
- "1,4,6" 指定的秒
- "1-10" 指定的连续秒
- times int 可选。重复运行的次数,执行过这个次数之后,就不再运行。默认不限制,无限循环。
- start datetime 可选。指定从具体的时间之后开始定时执行。默认从当前开始。如果指定日期,则从当日 00:00:00 开始
- until datetime 可选。指定到具体的时间之后停止循环。默认不停止。如果指定到日期,则到当日 23:59:59 结束
- cron 格式说明:
特别说明:
由于在PHP代码中,*/
是注释的结束标记,所以 crontab
表达式的 */5
无法使用,模块可以在表达式中使用 #
代替 *
。比如:#/5 # # # #
这样也是可以的。
日志
Crontab的运行日志在log/corntab
目录中。
All versions of crontab with dependencies
PHP Build Version
Package Version
Requires
uniondrug/framework Version
^2.0
uniondrug/server Version ^2.0
dragonmantank/cron-expression Version ^2.0
uniondrug/server Version ^2.0
dragonmantank/cron-expression Version ^2.0
The package uniondrug/crontab contains the following files
Loading the files please wait ....