【发布时间】:2017-08-18 03:32:08
【问题描述】:
我正在使用 PHP exec() 函数来执行 Canu assembler 程序,并且我想在同一个脚本中获取它的进程 ID。
问题是exec()没有返回任何PID,即使进程运行成功。
进程是这样启动的:
$gnuplot_path = '/usr/bin/gnuplot';
$command = 'nohup canu -d . -p E.coli gnuplot='.$gnuplot_path.' genomeSize=4.8m useGrid=false maxThreads=30 -pacbio-raw /path/to/p6.25x.fastq > /path/to/process.err 2>&1 &';
目前,我尝试通过以下方式确定进程是否仍在运行:
$pid = exec($command, $output);
var_dump($pid);
还有这个:
exec($command, $pid, $return_var);
print_r($pid);
echo "$return_var\n";
但是,我分别得到了string(0) "" 和Array ( ) 0 的输出。
请告诉我如何解决这个问题。非常感谢。
【问题讨论】:
-
使用
ps aux | grep "process name",然后解析pid的输出,exec()没有其他php shell相关函数返回一个pid,只有在它成功与否的情况下,也许输出。
标签: php exec bioinformatics pid dna-sequence