Jump to content

Exec out of PHP memory


inactive

Recommended Posts

Hi guys,

I don't know if I have the terminology correct here, but I'm trying to execute something in PHP [using exec() or system()], that runs separate from PHP, so that if the Apache service was to terminate (and hence PHP also), the executed program would still continue running.

 

I'm running PHP 5 on Apache 2.2 on XP SP2.

 

I am in effect wanting to restart Apache from within PHP i.e.:

exec('net stop Apache2.2');
sleep(10);
exec('net start Apache2.2');

 

Which would work, except that when Apache stops, the script terminates, and Apache doesn't get to start again.

 

So I tried to stick the following in  restart_apache.bat file:

net stop Apache2.2
sleep 10
net start Apache2.2

 

And then in the PHP script:

exec('restart_apache.bat');

 

Which should work right?

Except the restart_apache.bat script terminates prematurely because Apache stops, and then when it starts again, the browser displays a "The connection was reset" message, which is less than desirable.

 

So basically I would like the restart_apache.bat to run separate of PHP/Apache, so that as soon as it executes, the script has finished, and the connection to the browser completes properly. Then Apache can stop, and then start again 10 seconds later, and any further requests to Apache will be fine.

 

Any ideas? Thanks heaps.

Link to comment
https://forums.phpfreaks.com/topic/105697-exec-out-of-php-memory/
Share on other sites

I tried with the &, but the same thing occurred. I think it is actually running in the background already (as no command prompt window pops up or anything), but the PHP script will not finish until the .bat script terminates, i.e. the .bat cannot run exclusively, which is what I really need to do.

 

Daemon? I'm not sure what you mean...

 

Any other ideas out there?

 

Thanks anyway.

 

~Mitch.

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.