To run php script in background
Results 1 to 6 of 6

Thread: To run php script in background

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    4

    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. #2
    Senior Member dagon's Avatar
    Join Date
    Nov 2001
    Posts
    6,178
    PHP Code:
    $WshShell = new COM("WScript.Shell");
    $oExec $WshShell->Run("cmd /C dir /S %windir%"0false); 

  3. #3
    Junior Member
    Join Date
    Feb 2012
    Posts
    4
    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. #4
    Settled 4 red convertible dalecosp's Avatar
    Join Date
    Jul 2002
    Location
    Accelerating Windows at 9.81 m/s....
    Posts
    7,623
    Quote Originally Posted by Ajarwe View Post
    <?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'));
    ?>
    /!!\ mysql_ is deprecated --- don't use it! Tell your hosting company you will switch if they don't upgrade! /!!!\ ereg() is deprecated --- don't use it!

    dalecosp "God doesn't play dice." --- Einstein "Perl is hardly a paragon of beautiful syntax." --- Weedpacket

    Getting Help at All --- Collected Solutions to Common Problems --- Debugging 101 --- Unanswered Posts --- OMBE: Office Machines, Business Equipment

  5. #5
    PHP Witch laserlight's Avatar
    Join Date
    Apr 2003
    Location
    Singapore
    Posts
    13,459
    Warning: especially when using double quoted string literals, beware the backslashes.
    Use Bazaar for your version control system
    Read the PHP Spellbook
    Learn How To Ask Questions The Smart Way

  6. #6
    Senior Member
    Join Date
    Mar 2009
    Location
    Canada
    Posts
    794
    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.
    Prison of Mirrors
    Declare variables, not war.

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
  •