防止等待命令行输出
问题描述:
I thought that this would run without waiting for an output:
php /scripts/htdocs/summaries.live/app/scripts/generate-pdfs.php live 1 > /dev/null 2>&1
But it's not happening. PHP's exec() function is waiting for an output. How can I work around this to prevent this from happening?
我认为这可以在不等待输出的情况下运行: p>
php /scripts/htdocs/summaries.live/app/scripts/generate-pdfs.php live 1> / dev / null 2>& 1 code> pre>但它没有发生。 PHP的exec()函数正在等待输出。 我该如何解决这个问题以防止这种情况发生? p> div>
答
you're missing &
on the end of command
php /scripts/htdocs/summaries.live/app/scripts/generate-pdfs.php live 1 > /dev/null 2>&1 &
答
If running something with exec
, the documentation states
Note:
If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends.