Execute a script independent from the main script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nc3b
Forum Newbie
Posts: 3
Joined: Mon Nov 06, 2006 5:31 am

Execute a script independent from the main script

Post by nc3b »

Hello. I want to start a script from within another one and I want to child script to keep running even if the parent script stops. Can this be done? I know it can be done with exec, shell_exec, system, proc_open, popen, and so on. But what if the hosting company has disabled these functions. Is there any way to do this?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If they've disabled those functions, you're generally boned on the others.

cURL may be able to generate a remote request for the file (that doesn't wait), as could fsockopen(), fopen() and file_get_contents() (given proper directives are enabled.)
nc3b
Forum Newbie
Posts: 3
Joined: Mon Nov 06, 2006 5:31 am

Post by nc3b »

So you are saying I should run the script from another computer than the server? I don't understand very well what curl does.. :oops:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

cURL acts as another browser. It can make requests just like most browsers. If the file you wish to run can be requested via a URL, cURL seems like an option as you can tell it not to wait for any return information before returning itself.
Post Reply