Thanks guys ;)
I was just hoping of an idea to run a php script initiated by a visitor where a user wouldnt have to wait for the whole maintenance execution. I guess kind of like branching a single process into two. Thats something I havent done before; Im not sure if its possible.
Have a look at the PsExec tools (google it). With it you can run an external program, and choose to wait for it. This could do what you need.
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
Thanks guys ;)
I was just hoping of an idea to run a php script initiated by a visitor where a user wouldnt have to wait for the whole maintenance execution. I guess kind of like branching a single process into two. Thats something I havent done before; Im not sure if its possible.
Hi,
What you could do is use the exec() function in PHP that always to to execute shell commands. (Also see: popen, and proc_open() )
You can use the & option to run the command in the background.
Example:
[PHP]
<?php
exec( 'wget http://www.example.com/file.php > /dev/null &' );
?>
[/PHP]
The > /dev/null sends your php output to nowhere.
The & makes the wget run in the background.
You can use other commands rather than wget, but thats one Im sure of the syntax for.
If you cant use exec() then you could try using the HTTP protocol to your advantage to fork your php script for you.
I havent tested but I believe if you could do something like:
[PHP]
header( 'Location : http://www.example.com/new_file.php' );
echo str_pad(' ', 256); // make IE start rendering
flush();
// Do your other stuff here, in the background
// The browser is now fetching http://www.example.com/new_file.php
// Make sure you dont output anything
run_my_maintanence();
[/PHP]
I believe this will work.
For IE to actually start following the HTTP headers, it has to receive at least 256 bytes of content.. (now why?)
See if either of those work for you.
digital-ether
Nearly a Posting Virtuoso
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101
PHP does always run in the background it is server side scripting. something like javascript which is client side would run in the foreground.
mikeandike22
Nearly a Posting Virtuoso
1,496 posts since May 2004
Reputation Points: 33
Solved Threads: 19
digital-ether
Nearly a Posting Virtuoso
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101