ThinkPHP3.2.3はcliコマンドラインモードを使用します

<?php
if (version_compare(PHP_VERSION, '5.3.0', '<'))
die('require PHP > 5.3.0 !');
// 开启调试模式 建议开发阶段开启 部署阶段注释或者设为false
define('APP_DEBUG', TRUE);

//CLI
//define('APP_MODE','cli');
// 采用CLI运行模式运行
define('MODE_NAME','cli');
// 定义应用目录

define('APP_PATH', './Api/');
define('RUNTIME_PATH', './Runtime/');
define('APP_STATUS','dev');//开发环境
// 引入ThinkPHP入口文件
require 'ThinkPHP/ThinkPHP.php';

 

 

 

2.自动执行脚本

<?php
/**
* 自动执行脚本

*/

<?php
namespace Home\Controller;

class cronController extends CommonController {
    
    

  public function __construct () {
    
    
    parent::__construct ( true );
  }

public function updateStatusAction()
{
    
    

  if (IS_CLI) {
    
    
    $model = D('MediaAudit', 'Logic');
    $model->updateStatus($v)
  }
}


}


3.命令行执行
cd /home/www/mygit/API /home/system/php/bin/php Cron/cli.php /home/Cron/updateStatus

注/home/www/mygit/API是站点根目录,define('APP_PATH', './Api/');是相对根目录,/home是项目组
D:\phpstudy\PHPTutorial\php\php-5.6.27-nts\php  index.php Home/Test/redisPush

D:\phpstudy\PHPTutorial\php\php-5.6.27-nts\php  index.php Home/Test/redisPull

おすすめ

転載: blog.csdn.net/minihuabei/article/details/110917795