0
我有,我用它来在后台运行PHP脚本文件PHP类,就像这样:PHP后台进程查杀本身
Class BackgroundScript{
public $win_path = "C:\\xampp\\htdocs\\www\\project";
public $unix_path = "/home/my_folder/project.com";
public $script = NULL;
public $command = NULL;
public $pid = NULL;
public $start_time = NULL;
public $estimated_time = NULL;
public $ellapsed_time = NULL;
public $status_file = NULL;
...
public function kill(){
$this->removeFile();
if (self::get_os() == "windows"){
shell_exec(" taskkill /PID ".$this->pid);
} else{
shell_exec('kill '.$this->pid);
}
}
}
这就是所谓的这种方式:
$argvs = " var1 var2 ";
$process = new BackgroundScript("controller.php processCSV $argvs");
然后,创建一个在后台运行类似于此的代码的过程:
$current_process = BackgroundProcess::getByPID(getmypid());
for ($=1; $i< 100; $i++){
performLongRunningTask();
$current_process->updateStatus();
}
我想知道的是,有可能在第e结束循环,下面的命令:
$process->kill();
考虑到这个php文件是由我要杀的进程执行的吗?有什么副作用我应该考虑?
你只是想停止一个PHP过程?这是否正在运行多线程? – 2014-09-22 17:29:00
嗯....我没有准备好多线程的任何东西,但它应该能够一次运行多个实例。我想知道的是,如果shell_exec('kill'。$ this-> pid)之后有任何代码,会被执行,或者会立即停止。如果我不能更精确,我很抱歉,但是我对流程管理的知识非常薄弱,我不得不快速学习基本知识:P – sergio0983 2014-09-22 18:38:18