在后台执行shell脚本,同时页面在屏幕上显示给用户 [英] Execute shell script in the background while a page is displayed on screen to the user in php

查看:160
本文介绍了在后台执行shell脚本,同时页面在屏幕上显示给用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我正在运行一个shell脚本,但直到脚本完成执行屏幕为空。我无法在屏幕上显示任何内容。我希望将日志文件显示给用户,以便生成日志文件时,我希望用户在屏幕上看到一些文本内容。



我读过以前的问题 有没有一种方法可以做到这一点?

解决方案

这两个问题可能有一些帮助:
$ b

1> exec(sprintf(%s> ;%s 2& 1& echo $!>>%s,$ cmd,$ outputfile,$ pidfile));

php执行后台进程



2>
ignore_user_abort(true)


In my application, I am running a shell script but till the script completes executing the screen is blank. I am not able to display anything on screen. I want to display the log file to the user so till the log file is generated, i want the user to see some text content on the screen.

I read previous questions posted where they say multithreading in php is not possible.

Is there a way i can do this?

解决方案

These two questions might be of some help:

1> exec(sprintf("%s > %s 2>&1 & echo $! >> %s", $cmd, $outputfile, $pidfile));

php execute a background process

2> ignore_user_abort(true)

这篇关于在后台执行shell脚本,同时页面在屏幕上显示给用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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