To run php script in background

# Thread: To run php script in background

1. ## To run php script in background

Hi all,
I am very new to php,I have problem for running php script in backround.My issue is I have a .php (script1.php) file that should run in backround when i click the button in another php (script2.php) file.

Am using Windows xp
Php version 5.3.8
Apache server.

I googled and found like this..

<?php
$cmd="C:\wamp\www\Phpscript\script1.php"; pclose(popen("start /B ".$cmd, 'r'));
?>
but it is not helpful to me..Kindly suggest me any other way..
Thnaks

2. PHP Code:
 $WshShell = new COM("WScript.Shell");$oExec = $WshShell->Run("cmd /C dir /S %windir%", 0, false);  3. Hi,I have used to exec to run the php script in backround..But it not seems to be run in backround.. echo "successfully loaded"; exec("php D:/wamp/www/Test_krish/Email.php$List_name $C_name$c_id $L_No$path1 $path2 >outputVR.txt",$output);
The echo statemnet get displayed only after exec statement gets run..

Then i tried this

system("php D:/wamp/www/Test_krish/Email.php $List_name$C_name $c_id$L_No $path1$path2 > /dev/null &");

This is not working since am using windows xp...

How to make this to run in windows

Please help

Thanks in Advance
Ajarwe

4. Originally Posted by Ajarwe
<?php
$cmd="C:\wamp\www\Phpscript\script1.php"; pclose(popen("start /B ".$cmd, 'r'));
?>
but it is not helpful to me..Kindly suggest me any other way..
Thnaks
How about:

PHP Code:
 <?php$cmd="c:\path\to\php.exe C:\wamp\www\Phpscript\script1.php"; // PHP is an executable ... right?pclose(popen("start /B ".$cmd, 'r'));?> 

5. Warning: especially when using double quoted string literals, beware the backslashes.

6. I've always run my PHP scripts in the background using Scheduled Tasks. Those were scripts that needed to be run on a regular basis at a specific time, though.

#### Thread Information

##### Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•