This is mostly because the script is hang at some point , the server still keeps the connection, this will end up where server can’t accept new connection.
This is a dirty approach – it will kill all process having waiting time > 30s
#/bin/bash
#Delete all apache having process with waiting time >30s GetAllWorkers() { AllWorkers=$(apache2ctl fullstatus | grep ” W ” | awk ‘$6>30 {print $2}’)
for PID in $AllWorkers; do echo stopping $PID with SIGTERM kill -9 $PID done }
GetAllWorkers