首页 > php教程 > PHP源码 > discuz x1.5 计划任务改为系统层执行

discuz x1.5 计划任务改为系统层执行

PHP中文网
发布: 2016-05-25 17:10:51
原创
1049 人浏览过

1、添加cronrun.php文件

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

define('APPTYPEID', 1);

define('CURSCRIPT', 'cronrun');

if($argv['1'] != 'start'){

  

   header("HTTP/1.1 301 Moved Permanently");

    header("location: index.php");

    exit();

}

@ignore_user_abort(TRUE);

@set_time_limit(0);

require './source/class/class_core.php';

$discuz = & discuz_core::instance();

$discuz->init();

$timestamp = time();

$t = $timestamp + 600;

if($timestamp <= @filemtime(&#39;data/run.lock&#39;)){

    runlog("runlog.log",&#39;limit-run&#39;);

    exit();

}

 

@touch(&#39;data/run.lock&#39;, $t);

$query = DB::query("SELECT * FROM ".DB::table(&#39;common_cron&#39;)." WHERE `available`>&#39;0&#39; AND `nextrun`<=&#39;$timestamp&#39; ORDER BY nextrun");

while($cron = DB::fetch($query)) {

    $cron[&#39;filename&#39;] = str_replace(array(&#39;..&#39;, &#39;/&#39;, &#39;\\&#39;), &#39;&#39;, $cron[&#39;filename&#39;]);

    $cronfile = DISCUZ_ROOT.&#39;./source/include/cron/&#39;.$cron[&#39;filename&#39;];

    $cron[&#39;minute&#39;] = explode("\t", $cron[&#39;minute&#39;]);

    discuz_cron::setnextime($cron);

    if(!@include_once $cronfile) {

        runlog("runlog.log",&#39;Not find cronfile:&#39;.$cronfile);

        continue;

    }

    runlog("runlog.log",$cronfile);

}

@touch(&#39;data/run.lock&#39;, $timestamp);

登录后复制

2、将程序自动执行计划任务关闭

1

2

class_core.php

var $init_cron = false;

登录后复制


3、服务器添加系统计划任务 crontab

1

*/1 * * * * cd /data/wwwroot/bbs/ && chmod +x cronrun.php && /usr/local/php/bin/php cronrun.php start

登录后复制

           

本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
热门推荐
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板