ABKYH 发表于 2018-8-30 09:30:02

Shell脚本如何选择出log root-echo

  ###########################################################
  ######You should try to use root to check the log root#####
  ###########################################################
  #!/bin/sh
  if [ -f /var/tmp/vito/record_was_node.log ];then
  cat /dev/null>/var/tmp/vito/record_was_node.log
  else
  touch /var/tmp/vito/record_was_node.log
  fi
  if [ -f /var/tmp/vito/record_was_node.log ];then
  cat /dev/null>/var/tmp/vito/record_node_all.log
  else
  touch /var/tmp/vito/record_node_all.log
  fi
  if [ -f /var/tmp/vito/record_node_all_info.log ];then
  cat /dev/null>/var/tmp/vito/record_node_all_info.log
  else
  touch /var/tmp/vito/record_node_all_info.log
  fi
  ps -ef|grep was|grep node|grep -v grep |grep -i -v -w 'nodeagent'|sed 's/-/ '\\'\n /g'>/var/tmp/vito/record_was_node.log
  content=`cat /var/tmp/vito/record_was_node.log`
  echo $content>/var/tmp/vito/record_node_all.log
  echo "#######################################The node profile path##########################################################"
  cat /var/tmp/vito/record_node_all.log|grep -i -w 'application com.ibm.ws.bootstrap.WSLauncher com.ibm.ws.runtime.WsServer'|awk '{print $4}'>/var/tmp/vito/record_node_all_info.log
  cat /var/tmp/vito/record_node_all_info.log
  echo "#######################################The node profile path##########################################################"
  cat /var/tmp/vito/record_node_all_info.log|cut -d '/ ' -f7>/var/tmp/vito/nodes_info.log
  echo ""
  echo "#######################################The nodes information##########################################################"
  cat /var/tmp/vito/nodes_info.log
  echo "#######################################The nodes information##########################################################"
  echo ""
  echo "########################################The Server root is ###########################################################"
  server_root=`cat /var/tmp/vito/record_node_all.log|grep -i Dwas.install.root|sed -n '1p'|cut -d "=" -f2`
  echo $server_root
  echo "########################################The Server root is ###########################################################"
  nodes_dir=`cat /var/tmp/vito/record_node_all_info.log`
  echo ""
  echo "#############################The nodes diretory is####################################################################"
  echo $nodes_dir
  echo "#############################The nodes diretory is####################################################################"
  echo ""
  for i in `cat/var/tmp/vito/record_node_all_info.log`
  do
  echo ""
  echo "########################################################"
  echo "#########                                    #########"
  echo "##   The configuration of variable directory      ##"
  echo "##                                                    ##"
  echo "########################################################"
  echo "############The nodes direcotry is $i###################"
  export nodes_para=`echo $i|cut -d '/' -f7`
  echo "#########################################################"
  echo ""
  echo "#########################################################"
  export variable_para="$i/cells/ivrcell/nodes/$nodes_para/variables.xml"
  if [ -f $variable_para ];then
  echo "########The file exists######"
  echo "########The variable configuration file is :############"
  echo "$variable_para"
  else
  echo "######The file $variable_para does not exist###########"
  fi
  echo "#######################################################"
  echo ""
  echo "#######################################################"
  echo "The log root for $nodes_para is `cat $variable_para|grep log|grep -v grep|cut -d ' ' -f6"
  echo "#######################################################"
  done

页: [1]
查看完整版本: Shell脚本如何选择出log root-echo