Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
调用php passthru()函数后继续执行_Php_Passthru_External Script - Fatal编程技术网

调用php passthru()函数后继续执行

调用php passthru()函数后继续执行,php,passthru,external-script,Php,Passthru,External Script,使用php passthru()函数时,默认值是保留到外部脚本执行结束 PHP手册中说:“如果一个程序是用这个函数启动的,为了让它在后台继续运行,程序的输出必须重定向到一个文件或另一个输出流。否则,PHP将被挂起,直到程序的执行结束。” 我想收集特定时间的外部脚本数据,例如30秒,然后继续执行php脚本。有什么办法吗 我目前的代码是: ob_start(); passthru("/home/somefolder/somefolder2/program $pic1 $pic2");

使用php passthru()函数时,默认值是保留到外部脚本执行结束

PHP手册中说:“如果一个程序是用这个函数启动的,为了让它在后台继续运行,程序的输出必须重定向到一个文件或另一个输出流。否则,PHP将被挂起,直到程序的执行结束。”

我想收集特定时间的外部脚本数据,例如30秒,然后继续执行php脚本。有什么办法吗

我目前的代码是:

    ob_start();
    passthru("/home/somefolder/somefolder2/program $pic1 $pic2");
    $details = ob_get_contents();
    ob_end_clean();
上面代码中的问题是——有时“程序”脚本会持续执行一段时间,但我不想让用户在这个过程中等待超过30秒

我考虑将输出重定向到一个文件,并在30秒后读取它(根据手册)。但我不知道如何将输出重定向到文件

"/home/somefolder/somefolder2/program $pic1 $pic2 > /path/to/your/file 2>&1"
如果希望在后台运行,请在末尾添加
&

"/home/somefolder/somefolder2/program $pic1 $pic2 > /path/to/your/file 2>&1 &"
如果希望在后台运行,请在末尾添加
&

"/home/somefolder/somefolder2/program $pic1 $pic2 > /path/to/your/file 2>&1 &"

这是否会继续执行php脚本,而不会挂起,直到程序执行结束?如果让它在后台运行,那么php脚本的执行将不会挂起。请解释“2>&1”部分的目的?这是否会继续执行php脚本,没有挂起直到程序执行结束?如果你让它在后台运行,那么php脚本的执行将不会挂起。你能解释一下“2>&1”部分的目的吗?