通用kill shell外壳
?
#!/bin/bashappName="appName"appPsCommond="appPsCommond"appPath="/home/appPath"isRunning(){appPs=`ps -ef | grep "$appPsCommond" | grep -v "grep" | grep -v "stop" | awk ' { print $appPsCommond} '`if [ "$appPs" ]thenreturn 0fireturn 1}invokeStop(){if ! isRunningthenecho `date` `whoami` INFO: "the $appName is not running." >> /home/shellLogecho "the $appName is not running."exit 1fiif [ ! -d $appPath ]thenecho `date` `whoami` INFO: "$appPath not exist." >> /home/shellLogecho "$appPath not exist."exit 1fifor pid in `ps -ef | grep $appPsCommond | grep -v grep | grep -v stop | awk ' { print $2 } '`dokill -9 $pid;echo `date` `whoami` INFO: "killed pid: $pid ." >> /home/shellLogecho "killed pid: $pid ."done}if [ -z "$1" ]thenecho `date` `whoami` INFO: "command error.usage:$appName stop." >> /home/shellLogecho "command error. usage:$appName stop."elsecase $1 instop)invokeStop;;*)echo `date` `whoami` INFO: "command error.usage:$appName stop." >> /home/shellLogecho "command error. usage:$appName stop.";;esacfi