/opt/restart_hanged_http.sh
#!/bin/sh WAIT=10 PROC_MAX=250 RESTART_INTERVAL=60 TIMESTAMP_FILE=/tmp/restart_hanged_http SCRIPT_PATH=`echo $(cd $(dirname $0);pwd)` cd ${SCRIPT_PATH} if [ -f ${TIMESTAMP_FILE} ]; then if [ `find ${TIMESTAMP_FILE} -cmin +${RESTART_INTERVAL} | wc -l` -gt 0 ]; then rm -f ${TIMESTAMP_FILE}; fi fi if [ `ps auxww | grep httpd | wc -l` -gt ${PROC_MAX} ]; then sleep ${WAIT} if [ `ps auxww | grep httpd | wc -l` -gt ${PROC_MAX} ]; then if [ ! -f "${TIMESTAMP_FILE}" ]; then touch "${TIMESTAMP_FILE}" /sbin/service httpd restart fi fi fi
2分おきにcron実行
*/2 * * * * /bin/sh /opt/restart_hanged_http.sh > /tmp/restart_hanged_http.log 2>1&