在 PHP 上通过 shell_exec 执行 wget 是否允许我随时关闭浏览器而无需等待它完成下载


Does executing wget via shell_exec on PHP allows me to close the browser readily without waiting for it to finish the download?

我只是想知道(因为我没有我的 unix 平台来测试)如果我通过 PHP 上的shell_exec()执行多命令行,我是否已经安全地关闭浏览器而不等待它完成?

因为据我所知,wget会继续下载文件(这就是为什么它比 cURL 更有利于不稳定和慢速的网络)。

目前,我非常担心我的下载会中断,交叉检查每个文件是否已完成会产生更多的工作。

看看我的PHP生成的这个多行命令: 截至目前,它等待下载完成 wget "hxxp:// - 01 [480p][TSR][AKS].mkv" --user=root --password=pw --directory-prefix="download here" -nc 2>&1 && wget "hxxp:// - 01 Preview [480p][TSR][AKS].mkv" --user=root --password=pw --directory-prefix="download here" -nc 2>&1 && wget "hxxp:// - 02 [480p][TSR][AKS].mkv" --user=root --password=pw --directory-prefix="download here" -nc 2>&1 && wget "hxxp:// - 02 Preview [480p][TSR][AKS].mkv" --user=root --password=pw --directory-prefix="download here" -nc 2>&1 && wget "hxxp:// - 03 [480p][TSR][AKS].mkv" --user=root --password=pw --directory-prefix="download here" -nc 2>&1 && wget "hxxp:// - 03 Preview [480p][TSR][AKS].mkv" --user=root --password=pw --directory-prefix="download here" -nc 2>&1 && wget "hxxp:// - 04 [480p][TSR][AKS].mkv" --user=root --password=pw --directory-prefix="download here" -nc 2>&1 && wget "hxxp:// - 04 Preview [480p][TSR][AKS].mkv" --user=root --password=pw --directory-prefix="download here" -nc 2>&1

然后通过以下方式echo输出:

$output = shell_exec($exec);
echo $exec.'<br /><pre>'.$output.'</pre>';`

只要我知道即使我关闭 PHP 脚本,多行命令也会在后台执行,我就愿意删除上面的 2 行。

希望有人能给出他们的见解或建议。

谢谢!

这就像在命令字符串的末尾添加一个&一样简单,在后台运行wget,而不是让 PHP 等待命令退出。但是,您将无法从命令获取输出,因为脚本完成后它可能仍在运行。