有没有一种方法可以使用shell_exec而无需等待命令完成? [英] Is there a way to use shell_exec without waiting for the command to complete?

查看:82
本文介绍了有没有一种方法可以使用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天全站免登陆