You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
657 B
PHP

<?php
namespace Admin\Controller;
use Think\Controller;
use Think\Exception;
/**
* 系统任务接口
* @author cz
*/
class CmdTasksController extends Controller {
public function run()
{
$params = D("CmdTasks")->getTask();
if(!$params){
echo('暂无任务');
}
try {
exec($params['params'], $resArr, $status);
$result = json_encode($resArr,JSON_UNESCAPED_UNICODE);
D("CmdTasks")->updateTask(['id'=>$params['id'],'status' => 2, 'end_time' => time(), 'result' => $result]);
} catch (Exception $e) {
D("CmdTasks")->updateTask(['id'=>$params['id'],'status' => 3, 'end_time' => time(), 'result' => $e->getMessage()]);
}
}
}