2021年3月

    #关闭服务
public function closed(){

    if(strpos(PHP_OS,"Linux")!==false){
      #Linux套字
      $exec_power ="kill -s 9 `ps -aux | grep queue| grep -v grep | awk '{print $2}'`";
     //$exec_power ='cd '. ROOT_PATH .'; php think queue:restart';
    }else if(strpos(PHP_OS,"WIN")!==false){
     #Win套字
     $exec_power ='cd /d '. ROOT_PATH .' & php think queue:restart ';
    }else{
      $this->error('未识别的操作系统');
    }
    #命令执行
    $message ='';
    try {
       $message = shell_exec($exec_power);
    } catch (\Exception $e) {
       $message = $e->getMessage();
    }
    $this->success('关闭服务成功','',$exec_power);
}

#启动服务
public function powers(){
     $id =$this->request->param('id');
     $info=$this->model->where(array('id'=>$id))->find();
     $daemon =1;
     #获取标识
     $job_code =$info['job_code'];
     if(!empty($job_code)){
       #判断win还是linux
       if(strpos(PHP_OS,"Linux")!==false){
             #Linux套字
             if($daemon){
             //$exec_power ='cd '. ROOT_PATH .'; php think queue:work --queue ' .$job_code.' --daemon';
             //后台挂起 不同等待
             $exec_power ='cd '. ROOT_PATH .'; php think queue:work --queue ' .$job_code.' --daemon > /dev/null 2> /dev/null &';
             }else{
             $exec_power ='cd '. ROOT_PATH .'; php think queue:work --queue ' .$job_code;
             }
        }else if(strpos(PHP_OS,"WIN")!==false){
             #Win套字
             if($daemon){
               //$exec_power ='cd /d '. ROOT_PATH .' & php think queue:work --queue ' .$job_code.' --daemon';
               $exec_power ='cd /d '. ROOT_PATH .' & start /B php think queue:work --queue ' .$job_code.' --daemon';
             }else{
               $exec_power ='cd /d "'. ROOT_PATH .'" & php think queue:work --queue ' .$job_code;
             }
        }else{
          $this->error('未识别的操作系统');
        }
        #命令执行
        $message ='';
        if($daemon>0){
            $message =pclose(popen($exec_power, 'r'));
          //$message =shell_exec($exec_power);
        }else{
            try {
              $message = shell_exec($exec_power);
            } catch (\Exception $e) {
              $message = $e->getMessage();
            }
        }

        $this->success('启动成功','',$exec_power);
    
     }else{
       $this->error('未找到对应的任务标识');
     }
}

查找大于10M的日志文件

find / -name "*.log"  -size +10M

查找大于10M的日志文件并删除

find / -name "*.log"  -size +10M -exec rm -rf {} \;

查找大于1M的日志文件并删除

find / -name "*.log"  -size +1M -exec rm -rf {} \;

查找所有的日志文件并删除

find / -name "*.log"  -exec rm -rf {} \;

1.查看当前php-fpm的进程数

ps -fe |grep "php-fpm"|grep "pool"|wc -l 

2.查看tcp处理数

netstat -anp|grep "php-fpm"|grep "tcp"|grep "pool"|wc -l