trp Posted April 12, 2010 Share Posted April 12, 2010 Hi guys, I am using shell_exec to call a batch script, I don't need the batch to put any output on the page and - as it takes some time to run - I would love it to run in the background, however currently the page hangs untill the script has completed.. can any suggest how to run shell_exec in the background or other methods of running the script without the page hanging? Thanks in advance! TRP Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted April 12, 2010 Share Posted April 12, 2010 Use nohup. Quote Link to comment Share on other sites More sharing options...
trp Posted April 13, 2010 Author Share Posted April 13, 2010 I forgot to add, I am using Windows Server 2003. I have found this: http://gnuwin32.sourceforge.net/packages/coreutils.htm Which adds nohup functionality to Windows, it works fine when run directly from command prompt on the machine. However, the page calling shell_exec('nohup something.bat'); still hangs, if you have any further advice that would be great! TRP Quote Link to comment Share on other sites More sharing options...
trp Posted April 13, 2010 Author Share Posted April 13, 2010 I am now using the following code with great success. Thanks for the tips however! For reference: launchBackgroundProcess('start /b something.bat'); function launchBackgroundProcess($call) { $task = popen($call,'r'); pclose($task); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.