Guys the below is what I'm using now. It restarts httpd under stated condition. Is it possible to make it stop httpd and start again ONLY after certain timeframe like 15 minutes? Thanks for help #!/bin/bash loadavg=`uptime | awk '{print $10}'` RESTART="/etc/init.d/httpd restart" thisloadavg=`echo $loadavg|awk -F \. '{print $1}'` if [ "$thisloadavg" -ge "400" ]; then echo "restarting due to load being $thisloadavg" $RESTART elif [ "$thisloadavg" -le "400" ]; then echo Not restarting, load is $thisloadavg if [ $? -ne 0 ] then $RESTART fi fi Code (markup):
400 seems a bit high to setting load caps at. Might try something like this: #!/bin/bash MAX="15" LOAD="`uptime | awk '{print $10}' | sed -e 's/\,//'`" if [ "$LOAD" -gt "$MAX" ]; then echo "Current Load: $LOAD - Restarting HTTPD" /sbin/service httpd stop sleep 5 /sbin/service httpd start fi Code (markup): You also may want to tweak Apache a little bit, let me know if you need some help.
To stop after 15 minutes, you can use sleep 900 Code (markup): However, turn off httpd due to high server load is not recommended. You'd better try to optimize apache and your script.