killsmpser.sh

来源:互联网 发布:熟悉使用办公软件 编辑:程序博客网 时间:2024/05/17 04:44

#!/bin/ksh
#程序名称:killsmpser.sh
#作者姓名:**

#开发时间:2007-08-10
#功能说明:本程序用来杀掉调度进程smpser和其他被拉起的子进程

#包含公共函数集
. public.sh.rc

workdir=$HOME/smp_run/smpser

#日志文件
LogFile=${LogDir}/killsmpser.log


# ======   main   =========
ProgName=`basename $0`

#程序启动日志
LogStart $ProgName

SMPSER_PID=`ps -ef | grep "$LOGNAME" | grep "smpser" | grep -v  grep  |grep -v "_smpser"| grep -v "smpser_"| grep -v "killsmpser" | awk '{print $2}'`
for PID in $SMPSER_PID
do
  if kill -USR1 $PID
     then
        Log "Process smpser($PID) was stopped"
     else
        Log "Process smpser($PID) can not be stopped"
   fi
done
sleep 2

#smpser主进程输出的子进程列表
tmpfile=$workdir/temp/smpser_proclist.unl
if [ ! -f $tmpfile ]
then
    Log "No child process"
    #结束日志
    LogEnd $ProgName   
    exit 0
fi


#杀掉可能存在的子进程.
while read proname
do
    PROC_PID=`ps -ef | grep "$LOGNAME" | grep "$proname" | grep -v grep | awk '{print $2}'`
    for PID in $PROC_PID
    do
      if kill -9 $PID
         then
            Log "Process $proname($PID) was stopped"
         else
            Log "Process $proname($PID) can not be stopped"
       fi
    done
done < $tmpfile

Log "All child process were stopped"

#结束日志
LogEnd $ProgName

exit 0

原创粉丝点击