Jump to content

Getting php-cgi <defunct> in running proccess list ??


lostnucleus

Recommended Posts

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 )

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.