Linux中为什么我的批Kill进程不成功!求教。。。

笑羽酣天 2010-07-16 03:28:41
我kill前:
[root@ebisu ~]# ps -ef | grep -i tigase
root 17871 16125 0 14:55 pts/1 00:00:00 grep -i tigase
root 19200 19199 0 01:55 ? 00:00:05 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-ebisu.properties
root 22679 22678 0 Jul14 ? 00:00:10 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-ebisu.properties
root 23089 23088 0 Jul14 ? 00:00:10 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-ebisu.properties
root 23924 23923 0 Jul15 ? 00:00:08 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-ebisu.properties
root 24418 24417 0 Jul15 ? 00:00:08 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-ebisu.properties
root 24937 24936 0 04:22 ? 00:00:05 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-ebisu.properties
root 25037 25036 0 Jul15 ? 00:00:08 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-ebisu.properties
root 25385 25384 0 Jul15 ? 00:00:08 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-ebisu.properties
root 26299 26298 0 Jul15 ? 00:00:08 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-ebisu.properties
root 26694 26693 0 Jul15 ? 00:00:08 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-ebisu.properties
root 28408 28407 0 05:53 ? 00:00:05 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-ebisu.properties
root 28598 28597 0 Jul15 ? 00:00:08 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-ebisu.properties
root 29055 29054 0 Jul15 ? 00:00:08 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-ebisu.properties
root 29564 29561 0 Jul14 ? 00:00:11 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-mysql.properties
root 30651 30648 0 Jul14 ? 00:00:10 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-mysql.properties
root 30906 30903 0 Jul14 ? 00:00:11 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-mysql.properties
root 31131 31128 0 Jul14 ? 00:00:11 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-mysql.properties
root 31416 31413 0 Jul14 ? 00:00:11 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-mysql.properties
root 32001 31998 0 Jul14 ? 00:00:11 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-mysql.properties
root 32349 32346 0 Jul14 ? 00:00:11 java -cp jars/*:libs/* -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer --property-file etc/init-mysql.properties

执行我的shell脚本:


#!/bin/sh
tigase=`ps -ef | grep tigase | awk '{print $2}'`
if [ "$tigase" ]; then
echo -e "Checking Tigase services,PID is "${tigase}"...... [ \033[32mOK\033[m ]"
for test in ${tigase};do
echo "The PID IS find:"${test}"...now kill it..."
echo "Killed it sucessfully!"
done
else
echo -e "Checking Tigase services...... [ \033[31mNG\033[m ]"
fi

然后还是一样的结果,请问为什么呢?
很急的!!!
...全文
264 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
yanxu_1234 2010-07-16
  • 打赏
  • 举报
回复
顶10楼
steptodream 2010-07-16
  • 打赏
  • 举报
回复
ps -ef | grep tigase | grep -v grep | awk '{print $2}' | xargs kill -9
一句就行了 另外你的脚本名字里不要包含tigase关键字 否则像楼上说的把自己也给杀了
ecsape 2010-07-16
  • 打赏
  • 举报
回复
to 8楼:
我也这样怀疑,所以我才问他脚本名字
playmud 2010-07-16
  • 打赏
  • 举报
回复
tigase=`ps -ef | grep httpd |grep -v grep| awk '{print $2}'`
试试这个,我看你上面:Terminated
是不是把自己给kill了
ecsape 2010-07-16
  • 打赏
  • 举报
回复
脚本是对的,应该是别的地方的问题。
你的脚本是什么名字?
笑羽酣天 2010-07-16
  • 打赏
  • 举报
回复
我用的脚本是这样的:


#!/bin/sh
tigase=`ps -ef | grep tigase | awk '{print $2}'`
if [ "$tigase" ]; then
echo -e "Checking Tigase services,PID is "${tigase}"...... [ \033[32mOK\033[m ]"
for test in ${tigase};do
echo "The PID IS find:"${test}"...now kill it..."
kill -9 ${test}
echo "Killed it sucessfully!"
done
else
echo -e "Checking Tigase services...... [ \033[31mNG\033[m ]"
fi
playmud 2010-07-16
  • 打赏
  • 举报
回复
是你kill掉以后监测进程又启动了新进程?
手动kill和在shell里面kill是一样的,找找其他原因吧。

ps -ef | grep tigase |awk '{pring $2}'
然后找个pid,在shell里面kill一下,然后查看这个进程是否还在?
笑羽酣天 2010-07-16
  • 打赏
  • 举报
回复
哦,我脚本里写的有,这个是我测试用的,当时没有加的,没错的,我有kill -9 ${test} 这一句的
可是结果是:

Checking Tigase services,PID is 19856 19857 26694 28408 28598 29055 29564 30651 30906 31131 31416 32001 32349...... [ OK ]
The PID IS find:19856...now kill it...
Terminated

我如果用ps -ef | grep tigase |awk '{pring $2}'查看的话,一个一个在命令行手动是可以kill掉的,这是为什么呢?
wwwunix 2010-07-16
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 ecsape 的回复:]

脚本里你的kill命令呢?我怎么没找到呢?
[/Quote]
估计漏写了。:-)
ecsape 2010-07-16
  • 打赏
  • 举报
回复
你少了kill命令吧?

for test in ${tigase};do
echo "The PID IS find:"${test}"...now kill it..."
kill -9 ${test}
echo "Killed it sucessfully!"
done
ecsape 2010-07-16
  • 打赏
  • 举报
回复
脚本里你的kill命令呢?我怎么没找到呢?

19,612

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧