php discuz 定时计划,discuz x1.5 计划任务改为系统层执行

1、添加cronrun.php文件

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('data/run.lock')){

runlog("runlog.log",'limit-run');

exit();

}

@touch('data/run.lock', $t);

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

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

$cron['filename'] = str_replace(array('..', '/', '\\'), '', $cron['filename']);

$cronfile = DISCUZ_ROOT.'./source/include/cron/'.$cron['filename'];

$cron['minute'] = explode("\t", $cron['minute']);

discuz_cron::setnextime($cron);

if(!@include_once $cronfile) {

runlog("runlog.log",'Not find cronfile:'.$cronfile);

continue;

}

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

}

@touch('data/run.lock', $timestamp);

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

var $init_cron = false;

3、服务器添加系统计划任务 crontab*/1 * * * * cd /data/wwwroot/bbs/ && chmod +x cronrun.php && /usr/local/php/bin/php cronrun.php start

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值