子进程与主进程分开 bash shell php
我正在从我的 php 代码中调用销售脚本 和
foreach ($some_array) {
shell_exec(nohup $code);
}
像上面一样,
我希望所有 shell_exec
调用独立于邮件进程工作,该进程是我们称为 shell 脚本的 php 执行,
但它没有像我预期的那样工作,所有 shell_executions 在上一个执行完成后立即启动
那么我该如何做shell_exec
作为独立的子进程调用,它们不会等待彼此完成
提前感谢
I' am calling sell script from my php code
with
foreach ($some_array) {
shell_exec(nohup $code);
}
like above
I want all shell_exec
call to work independent from mail process which is php execution that we call shell script
But It's not working as I expected all shell_executions start right after previous one completed
So how can I make this shell_exec
calls as independent child process that they don't wait each others completation
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
添加“&”到您要执行的命令的末尾,以便它在后台运行。
Add the '&' to the end of the command you want to execute so it works in background.
对于一系列命令,请将它们括在括号内,然后附加 &符号,但请确保将 stdout、stderr 重定向到某处,否则您的脚本将挂起等待,例如:
请参阅 http://us.php.net/manual/en/function.exec.php
For a sequence of commands, enclose them within parentheses then append the & symbol but be sure to redirect stdout, stderr somewhere otherwise your script will hang waiting e.g.:
See http://us.php.net/manual/en/function.exec.php
将它们发送到后台
Send them to the background