开发者

PHP exec(), can I fire and forget?

I have been trying to execute a java application through a php form .. so the submit button fire an execute command:

exec("java -jar c:\edu.uniroma3.jar c:\parameter2BPassed");
开发者_如何学编程

The first path determines where the jar file is, the 2nd one serves as a parameter.

The problem is that the script takes too long to be processed and I would like to bypass the waiting, is there anyway to do it (like a fire and forget)? The script writes results into a file, and I can check every 5 minutes if the file is there, but it's inconvenient getting stuck waiting for the process to finish...

any suggestions ?

thank you in advance


I think this is the same problem

Asynchronous shell exec in PHP

As comments note the above works only in *nix environment but I found a similar to this for windows:

http://www.somacon.com/p395.php

Still, it might be better to think about other solutions like a separate process which you can send work to that is not connected to the webserver.

Webservers sometimes recycle processes and background processes are not always isolated as far as I have read so you might have your external process killed unless it is completly separate.


i would like to add the solution here aswell:
$shell = new COM("WScript.Shell");
$shell->run($command, 0, false);

worked like magic :) thx alot ircmaxell


Since you are on windows and you need to start a java program, you can use the javaw.exe instead of java.exe.

javaw on windows, is designed to start a jvm without open a cmd window. Maybe it could help


On MSWindows try:

exec("start java -jar c:\edu.uniroma3.jar c:\parameter2BPassed");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜