這個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