killall httpd for sleep process

Posted by user172697 on Stack Overflow See other posts from Stack Overflow or by user172697
Published on 2009-12-05T06:57:12Z Indexed on 2010/04/06 10:03 UTC
Read the original article Hit count: 302

Filed under:

Hello guys this shell explain the issue , after executing the .sh file halt and nothing happen , any clue where is my mistake

its kill httpd if there is more than 10 sleep process and start the httpd with zero sleep process

#!/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

© Stack Overflow or respective owner

Related posts about shell