#!/bin/sh
#写法一
#该语句表面列出所有有tomcat进程的编号,但只输出pid列,同时得第8列不包含grep自身进程号,然后将值输入给tpid,供下面kill
ps-ef|greptomcat|awk'{if($8!~/grep/)print$2}'|whilereadtpid
do
kill-9$tpid
done
#写法二
tpid=$(ps-ef|greptomcat|awk'{if($8!~/grep/)print$2}')
kill-9$tpid
转载于:https://blog.51cto.com/481814/1306920