Thinkphp的cron计划任务

栏目: PHP · 发布时间: 8年前

内容简介:Thinkphp的cron计划任务

1、使用方法

首先明白一点,thinkPHP中的计划任务不是真正意义上的,它是使用一个文件的修改时间差来比较是否执行,并且必须依赖网站的访问才能触发脚本

在conf下新建两个文件并配置tags.PHP和crons.PHP

Thinkphp的cron计划任务

配置tag.PHP

return array( 'app_end'=>array('/Behavior/CronRun'), // 定时任务 );

配置crons.PHP

return array( 'cron_1'=>array('cron1', '10') //cron1要执行的脚本 )

cron1默认在

Think<a href="https://www.52bz.la/tag/php" title="PHP" target="_blank">PHP</a>/Library/Cron/cron1.<a href="https://www.52bz.la/tag/php" title="PHP" target="_blank">PHP</a>

如果没有cron目录则新建一个,cron1.PHP自己所要执行的脚本

注意:

app_end的路径配置,

/Behavior/CronRun

路径要包含

/

否则不被认为是Behavior

如果报错Log::write相关错误,则打开

ThinkPHP/Library/Behavior/CronRunBehavior.class.<a href="https://www.52bz.la/tag/php" title="PHP" target="_blank">PHP</a>

大约55行

/Think/Log::write(implode('',$log));

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Data Structures and Algorithms

Data Structures and Algorithms

Alfred V. Aho、Jeffrey D. Ullman、John E. Hopcroft / Addison Wesley / 1983-1-11 / USD 74.20

The authors' treatment of data structures in Data Structures and Algorithms is unified by an informal notion of "abstract data types," allowing readers to compare different implementations of the same......一起来看看 《Data Structures and Algorithms》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具