lostnucleus Posted March 22, 2009 Share Posted March 22, 2009 I wrote a script to restart my webserver whenver http header is not 200 Ok , i added it to crontab to run every 15 mins but the problem is i see " php-cgi <defunct> " in running proccess list (by using top command) after 5 hrs or so ......it slows down the server , wat could be the reason for it , below is the code of my script........ <?php set_time_limit(0); $s = curl_init(); curl_setopt($s,CURLOPT_URL,"http://mysite.com/"); curl_setopt($s,CURLOPT_RETURNTRANSFER,TRUE); curl_setopt($s,CURLOPT_HEADER,TRUE); curl_setopt($s,CURLOPT_NOBODY,TRUE); curl_setopt($s,CURLOPT_FOLLOWLOCATION,TRUE); curl_setopt($s,CURLOPT_TIMEOUT,6); curl_setopt($s,CURLOPT_MAXREDIRS,4); $webpage = curl_exec($s); echo $webpage; curl_close($s); $time_stamp = date("F j, Y, g:i a",time()+ (315*120)); if(!strstr($webpage,"HTTP/1.1 200 OK")){ exec("service lighttpd restart",$output); $data_out = "At $time_stamp HTTP request was not 200 OK server restarted \n "; mail("[email protected]","Hi 500 Error Found on mysite.com ","$data_out"); } unset($output); unset($webpage); exit; ?> ( i dont know bash scripting thats y using php here to do the job for me ) Link to comment https://forums.phpfreaks.com/topic/150571-getting-php-cgi-in-running-proccess-list/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.