如何执行一个运行日志时间的cmd命令

when i make server with phantomjs that listen for some port this file open for long time . i use this code for excute phantomjs with php :

exec('phantomjs server.js');

ans for example phantomjs server file is

if (system.args.length !== 2) {
    console.log('Usage: server.js <some port>');
    phantom.exit(1);
} else {
    port = system.args[1];
    var listening = server.listen(port, function (request, response) {
        console.log("GOT HTTP REQUEST");
        console.log(JSON.stringify(request, null, 4));

        // we set the headers here
        response.statusCode = 200;
        response.headers = {"Cache": "no-cache", "Content-Type": "text/html"};
        // this is also possible:
        response.setHeader("foo", "bar");
        // now we write the body
        // note: the headers above will now be sent implictly
        response.write("<html><head><title>YES!</title></head>");
        // note: writeBody can be called multiple times
        response.write("<body><p>pretty cool :)</body></html>");
        response.close();
    });

because phantomjs server stay long time to answer and exit from it , i cant run other code that below exec line.

is any way to run it from php well .. ?


Problem Solve With:

$WshShell = new COM("WScript.Shell");
$run_cmd = "cmd c:/xampp/php/php.exe c:/xampp/htdocs/Gashash/batch_test.php";
$WshShell = $WshShell->Run($run_cmd, 0, false);

You could run the script in the background. But you lose control over the process.

exec('phantomjs server.js > /dev/null &');

You could also use something like beanstalk / Gearman to separate the two processes.