Php exec()未返回进程ID
我使用PHPPhp exec()未返回进程ID,php,exec,bioinformatics,pid,dna-sequence,Php,Exec,Bioinformatics,Pid,Dna Sequence,我使用PHPexec()函数来执行程序,我希望在同一个脚本中获取其进程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.25
exec()
函数来执行程序,我希望在同一个脚本中获取其进程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
的输出
请让我知道如何解决这个问题。非常感谢。这一个很棘手。我要做的是:
$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';
$command .= ' & echo $!';
$pid = exec($command, $output, $a);
var_dump($output[0]);
使用
ps aux | grep“process name”
,然后解析pid的输出,exec()
noor或其他php shell相关函数返回pid,你能解释一下你在这里到底做了些什么吗?我正在后台执行一个脚本,得到的空字符串与OP使用exec($command,$output)得到的字符串相同代码>是否必须在命令或其他内容中使用任何特定标志。