PHP脚本后台运行
error_reporting(E_ALL);
if(!function_exists('ignore_user_abort')){
exit('Function ignore_user_abort is not exists!');
}
if(!function_exists('set_time_limit')){
exit('Function set_time_limit is not exists!');
}
ignore_user_abort(true);
set_time_limit(0);
while(1 == 1){
if(file_exists('close.txt')){
exit();
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.baidu.com');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
// file_put_contents(time().'_'.memory_get_usage().'.txt', '');
$memory = memory_get_usage();
if($memory > 20*1024*1024){
exit();
}
sleep(2);
}