我开始这个过程(time.PHP)
<?PHP ignore_user_abort(true); // run script in background set_time_limit(0); // run script forever $interval = 300; // do every 1 minute... do { // add the script that has to be ran every 1 minute here // ... $to = "xxxxxxxxx@gmail.com"; $subject = "Hello Richie"; $header = "From: me@xxxxxxxxx.org"; $body = "Hello Richard,\n\n" . "I was just testing this service\n\n " . "Thanks! "; mail($to,$subject,$body,$header); sleep($interval); // wait 5 minutes } while(true); ?>@H_403_3@但我现在想阻止它.它发送数百邮件到我的Gmail a / c.它在一个Web服务器上,我不能重新启动它来杀死进程. @H_403_3@有没有办法执行另一个文件来杀死进程,或者我该怎么办?
如果没有shell访问,那么唯一的办法就是要求服务器管理员杀死进程.
@H_403_3@话虽如此,有一个简单的方法来设置脚本,并使其能够从同一服务器上的任何其他脚本取消,如下所示:
原文链接:https://www.f2er.com/php/131125.html<?PHP // at start of script,create a cancelation file file_put_contents(sys_get_temp_dir().'/myscriptcancelfile','run'); // inside the script loop,for each iteration,check the file if ( file_get_contents(sys_get_temp_dir().'/myscriptcancelfile') != 'run' ) { exit('Script was canceled') ; } // optional cleanup/remove file after the completion of the loop unlink(sys_get_temp_dir().'/myscriptcancelfile'); // To cancel/exit the loop from any other script on the same server file_put_contents(sys_get_temp_dir().'/myscriptcancelfile','stop'); ?>