有没有办法在不等待命令完成的情况下使用 shell_exec? [英] Is there a way to use shell_exec without waiting for the command to complete?

查看:25
本文介绍了有没有办法在不等待命令完成的情况下使用 shell_exec?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个流程密集型任务,我想在后台运行.

I have a process intensive task that I would like to run in the background.

用户点击一个页面,PHP脚本运行,最后,根据一些条件,如果需要,那么它必须运行一个shell脚本,例如:

The user clicks on a page, the PHP script runs, and finally, based on some conditions, if required, then it has to run a shell script, E.G.:

shell_exec('php measurePerformance.php 47 844 email@yahoo.com');

目前我使用 shell_exec但是这需要脚本等待一个输出.有没有什么方法可以在不等待它完成的情况下执行我想要的命令?

Currently I use shell_exec, but this requires the script to wait for an output. Is there any way to execute the command I want without waiting for it to complete?

推荐答案

如何添加.

"> /dev/null 2>/dev/null &"

shell_exec('php measurePerformance.php 47 844 email@yahoo.com > /dev/null 2>/dev/null &');

注意这也摆脱了 stdio 和 stderr.

Note this also gets rid of the stdio and stderr.

这篇关于有没有办法在不等待命令完成的情况下使用 shell_exec?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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