run php file in another php file using predis

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lordlinus
    New Member
    • Aug 2012
    • 1

    run php file in another php file using predis

    i have two fils named `index.php` and cron.php. i have written some logic of sending mail in cron.php. when i call index.php then i want that cron.php should run in bacground. how can i do that
    This is my `index.php`
    Code:
    $x=array('to'=>'ucerturohit@gmail.com','name'=>'Rohitashv singhal');
    
              $client = new \Predis\Client();
              $client->select(4);
              $client->lpush('xxxx',$x['to']);
    
    
    //         $command = "/usr/bin/php5 -f /var/www/Symfony/src/Ens/NewBundle/Controller/test.php";
    
                   $arrOutput=shell_exec('php test.php');
                    print_r($arrOutput);
    
            //      echo shell_exec('php test.php');
               return $this->render('EnsNewBundle:Email:header.html.twig');
        }
    and this is my test.php
    Code:
    require '/var/www/predis/autoload.php';
            \Predis\Autoloader::register();
    
    echo "hi";
    
    require_once('Services/Notification.php');
    
    $client = new \Predis\Client();
              $client->select(4);
    
    $u=$client->blpop('xxxx',0);
    
    var_dump($u);
    
    notification_on_signup($u[1]);
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    1. You can simply include the corn.php

    it wont help with the issue of running in background.

    2. You can simply send an http request to your own browser and ignore the reply.
    it wont help with the issue of running in background either.

    3. If you have system permission then you can execute your php file with php
    it wont also help with the issue of running in background.

    and also you can look at this answer

    Comment

    Working...