<?php
if (version_compare(PHP_VERSION, '5.3.0', '<'))
die('require PHP > 5.3.0 !');
define('APP_DEBUG', TRUE);
define('MODE_NAME','cli');
define('APP_PATH', './Api/');
define('RUNTIME_PATH', './Runtime/');
define('APP_STATUS','dev');
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