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 Link to comment https://forums.phpfreaks.com/topic/198325-shell_exec/ Share on other sites More sharing options...
Ken2k7 Posted April 12, 2010 Share Posted April 12, 2010 Use nohup. Link to comment https://forums.phpfreaks.com/topic/198325-shell_exec/#findComment-1040624 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 Link to comment https://forums.phpfreaks.com/topic/198325-shell_exec/#findComment-1040840 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); } Link to comment https://forums.phpfreaks.com/topic/198325-shell_exec/#findComment-1040944 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.