这个shell执行sh文件停止并没有发生之后解释这个问题, ,任何线索,哪里是我的错killall httpd的睡眠过程
它的猎物的httpd,如果有超过10个的睡眠过程,并启动httpd与零睡眠过程
#!/bin/bash
#this means loop forever
while [ 1 ];
do HTTP=`ps auwxf | grep httpd | grep -v grep | wc -l`;
#the above line counts the number of httpd processes found running
#and the following line says if there were less then 10 found running
if [ $[HTTP] -lt 10 ];
then killall -9 httpd;
#inside the if now, so there are less then 10, kill them all and wait 1 second
sleep 1;
#start apache
/etc/init.d/httpd start;
fi;
#all done, sleep for ten seconds before we loop again
sleep 10;done
的rueslt谈到这样 + '[' 1 ']' ++ PS auwxf ++的grep的httpd ++的grep -v grep的 ++ WC -l + HTTP = 72 + '[' 72 -lt 10 ']' +睡10 + '[' 1 ']' ++ PS auwxf ++的grep的httpd ++的grep -v grep的 ++ WC -l + HTTP = 70 + '['70 -lt 10']' + sleep 10 +'['1']' ++ ps auwxf ++ grep httpd ++的grep -v grep的 ++ WC -l + HTTP = 67 + '[' 67 -lt 10 ']' +睡10 和不会导致死亡的httpd所有睡眠过程中的任何线索 – user172697 2009-12-05 07:51:24
由于HTTP =例如72,而72不是“-lt”10。你正在测试“小于”('-lt'意思是“小于”),你的评论在两个地方说“小于”,但你的问题说“如果超过10就杀死httpd”。如果您希望以不同的方式工作,您必须更改测试的条件。否则,根据脚本和跟踪输出,它正常工作。 – 2009-12-05 11:05:26