exec()不返回进程ID [英] exec() not returning process ID

查看:137
本文介绍了exec()不返回进程ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PHP exec()函数执行

I'm using the PHP exec() function to execute the Canu assembler programs, and I want to get its process ID within the same script.

问题是exec()即使进程成功运行也不返回任何PID.

The problem is exec() not returning any PID, even the process is running successfully.

过程是这样开始的:

$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 &';

当前,我尝试确定进程是否仍在运行:

Currently, I try to determine if the process is still running by:

$pid = exec($command, $output);
var_dump($pid);

还有这个:

exec($command, $pid, $return_var);
print_r($pid);
echo "$return_var\n";

但是,我分别得到了string(0) ""Array ( ) 0的输出.

However, I got output of string(0) "" and Array ( ) 0 respectively.

请让我知道如何解决此问题.非常感谢.

Please let me know how to solve this. Thanks much.

推荐答案

这很棘手.我会怎么做:

This one is tricky. What I would do:

$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]);

这篇关于exec()不返回进程ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆