String command= "disspid=$(ps -ef | grep " +jobname +" | grep -v 'grep' |grep root | awk '{ print $2}' | sort -r | sed -n '1 p');" + "for i in $(pstree -p ${disspid:=999999999999999999} |grep -Po '(?<=\\050)[^\\051]+');" + "do kill $i;done;"; logger.info("kill job command : {}",command); String[] cmdA = { "/bin/sh", "-c", command }; process = Runtime.getRuntime().exec(cmdA);
通过pstree 找到进程所有子孙进程的pid 然后kill掉