Jump to content

shell_exec();


trp

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.