Both set_time_limit(...) and ini_set('max_execution_time',...); won't count the time cost of sleep,file_get_contents,shell_exec,mysql_query etc, so i build this function my_background_exec(), to run static method/function in background/detached process and time is out kill it: my_exec.php: <?php function my_background_exec($function_name, $params, $str_requires, $timeout=600) {$map=array('"'=>'\"'