spell 发表于 2018-8-21 13:06:25

shell两个变量调用方法

# cat listen_monitor.sh  
#!/bin/sh
  
#set -x
  
pid1=`ps -ef|grep QD|grep -v grep |awk '{print $14}'|grep QWorld`
  
pid2=`ps -ef|grep QD|grep -v grep |awk '{print $14}'|grep QDBProxy`
  
pid3=`ps -ef|grep QD|grep -v grep |awk '{print $14}'|grep QGameServer`
  
pid4=`ps -ef|grep QD|grep -v grep |awk '{print $14}'|grep QGateway`
  
pid5=`ps -ef|grep QD|grep -v grep |awk '{print $14}'|grep QCommunity`
  
DC_PATH=/usr/local/services/CloudDCAgent_L5-1.0/alarm
  
for i in {1..5}
  
do
  
a=pid
  
eval pidname="$"$a$i
  
#echo $pidname
  
if [ -z pid$i ]
  
then
  
$DC_PATH/cloud_alarm 100697808 "the rpgserver is down" -o rpgserver
  
echo $pidname "The process of death, to save it,now"
  
else
  
echo "everything is ok" >/dev/null 2>&1
  
fi
  
done


页: [1]
查看完整版本: shell两个变量调用方法