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(" ", $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
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号