I have built a system that has been in a live environment now for about 6 months, every now and then I notice the script gets hung up on the server, then once one does 4 to 8(+/- a few) more processes get hung up too and just sit there building the server load up, then more connections time out and it causes problems. I then have to go in there and manually kill each process that appears to be hung up. I know not all of them are because we have at any point in time around 40+ people on the website.
Is there a way for me to kill the process running if the script hangs for more than 10 seconds? Every process I run in the script should take no longer on the server than 0.4 seconds to 1 second.