本文介绍了PHP Exec:无需等待,无需丢弃输出,无需nohup的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要像这样在PHP中运行命令:

I need to run a command in PHP like this:

exec('dosomething > saveit.txt');

除了我不希望PHP等待它完成.我也不想丢弃输出,也不想使用nohup,因为我将其用于同一目录中的其他内容.

Except I don't want PHP to wait for it to be complete. I also don't want to throw away the output, and I don't want to use nohup because I'm using that for something else in the same directory.

我还尝试了pclose(popen('dosomething > saveit.txt','r'));,但没有成功,它仍然在等待.

I also tried pclose(popen('dosomething > saveit.txt','r')); and that didn't work, it still waited.

推荐答案

向其中添加&符命令的结尾,所以:

Add an ampersand to the end of the command, so:

exec('dosomething > saveit.txt &');

这篇关于PHP Exec:无需等待,无需丢弃输出,无需nohup的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-05 08:20