Jump to content

Executing files on server without waiting for output.


dayfox

Recommended Posts

Hi!

I'm trying to write a PHP script that will execute a batch command on the server (to republish some database related analytic tools), the batch script takes around 10 minutes to complete.

 

I am currently using the exec() function with the page time limit set to 0.

 

I was wondering how (if it's possible) to fire off a batch script....without the page waiting to load.

I.e, page loads, batch script continues in the background, page is loaded successfully.

 

Hopefully I've explained this well enough.... your ideas and help would be most appreciated!

 

Thanks :D

If you are triggering it from a web page then you can use an ajax call to trigger the script which will mean the page will not wait for it to complete, but the page can be updated on completion. If you are triggering this from the command line, then you can place it in the background.

Hi and thanks for your response!

I've come up with another way to do this...using eventtriggers.

 

Thought I would post my solution, in case anybody was in a similar situation...

 

Because the batch takes 10 minutes to complete, the page would take about ten minutes to load, and would probably timeout.

 

So I created an eventtrigger that will fire off the 10 minute batch when it sees a log with Event ID 999, and I have created a PHP file which will passthru the command to create said log. The page loads immediately, and the batch file continues in the background.

 

Cheers

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.