Blogger Information
Blog 51
fans 0
comment 1
visits 64956
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Windows 宝塔 ThinkPHP3.23执行cli任务
鱼的熊掌
Original
952 people have browsed it

1、在网站根目录创建cli.php文件

  1. <?php
  2. if(version_compare(PHP_VERSION,'5.3.0','<')) die('require PHP > 5.3.0 !');
  3. //普通模式,解决官方分组不支持cli的问题
  4. $depr = '/';
  5. $path = isset($_SERVER['argv'][1])?$_SERVER['argv'][1]:'';
  6. if(!empty($path)) {
  7. $params = explode($depr,trim($path,$depr));
  8. }
  9. !empty($params)?$_GET['g']=array_shift($params):"";
  10. !empty($params)?$_GET['m']=array_shift($params):"";
  11. !empty($params)?$_GET['a']=array_shift($params):"";
  12. if(count($params)>1) {
  13. // 解析剩余参数 并采用GET方式获取
  14. preg_replace('@(\w+),([^,\/]+)@e', '$_GET[\'\\1\']="\\2";', implode(',',$params));
  15. }
  16. //define('APP_MODE','cli');
  17. define('APP_DEBUG',True);
  18. define( 'APP_PATH', dirname(__FILE__).'/Application/' );
  19. require dirname(__FILE__).'/ThinkPHP/ThinkPHP.php';

2、php.exe必须配置在系统变量

3、宝塔添加shell任务
// 访问网站根目录 运行cli 同步用户
cd D:\wwwroot\website && php cli.php Home/Sync/user

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post