Home > Backend Development > PHP Tutorial > ignore_user_abort(1) 且set_time_limit(0)然后设置了无限循环,如何终止呢?

ignore_user_abort(1) 且set_time_limit(0)然后设置了无限循环,如何终止呢?

WBOY
Release: 2016-06-23 14:20:29
Original
1318 people have browsed it

本帖最后由 zhoumengkang 于 2013-08-09 17:24:21 编辑


今天看手册上的ingore_user_abort()里面有这样的例子,的确可以无限执行下去。但是如果终止这个进程呢?呵呵,,手册上的例子中没有说。 不重启服务器的情况下。怎么找到那个进程,然后终止?
ignore_user_abort(0); // run script in background set_time_limit(0); // run script forever $interval=2; // do every 15 minutes... do{ 	$data = '1<br/>';	file_put_contents('./test.html',$data,FILE_APPEND);    sleep($interval); // wait 15 minutes }while(true); 
Copy after login


回复讨论(解决方案)

cli模式下

<?php$pid = getmypid();ignore_user_abort(0);set_time_limit(0);  $interval=200; do{     echo "$pid"; //获取pid    sleep($interval);}while(true);
Copy after login
Copy after login
Copy after login


kill pid

打错了,是

 ignore_user_abort(1); 
Copy after login

cli模式下

<?php$pid = getmypid();ignore_user_abort(0);set_time_limit(0);  $interval=200; do{     echo "$pid"; //获取pid    sleep($interval);}while(true);
Copy after login
Copy after login
Copy after login


kill pid 以后可以像你这样写,如果像我上面没有写getmypid呢。。。只能去linux去找啦?


cli模式下

<?php$pid = getmypid();ignore_user_abort(0);set_time_limit(0);  $interval=200; do{     echo "$pid"; //获取pid    sleep($interval);}while(true);
Copy after login
Copy after login
Copy after login


kill pid 以后可以像你这样写,如果像我上面没有写getmypid呢。。。只能去linux去找啦?

没有pid进程不好找呀不是?
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template