首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

通用kill shell壳子

2012-06-26 
通用kill shell外壳?#!/bin/bashappNameappNameappPsCommondappPsCommondappPath/home/appPathis

通用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

热点排行