$xtar_command = "php -q gen_pcf_list.php $trs_adTradeId &";
  
`$xtar_command`;其中“$trs_adTradeId”是经过处理的以空格分开的一组ID,gen_pcf_list.php是根据接收ID在数据库中查找相关的配置,然后写入PCF文件当中。可是这样我觉得没有真正在后台运行
,运行时还是要经过执行完进程后才跳转到别的内容上,不是想像中的那样一执行这个,立即跳转到别的内容。

解决方案 »

  1.   

    装的时候激活Process Control Functions
    使用 pcntl_fork 函数开辟新进程~~
      

  2.   

    php -q gen_pcf_list.php $trs_adTradeId &";
    我这样执行命令可以吗,是不是在后台运行的进程呀???
      

  3.   

    命令行
    php -q gen_pcf_list.php xxxxx &
    肯定是在后台开了一个php进程
    但是
    $xtar_command = "php -q gen_pcf_list.php $trs_adTradeId &";
    `$xtar_command`;
    就不是了
    php要等待`$xtar_command`;结束的
    你可能要写成
    $xtar_command = "php -q gen_pcf_list.php $trs_adTradeId &
    exit";
    多行命令应该如何写,我没有了linux环境,不好说
    总之,执行的命令应该是后台启动一个php进程后,立刻返回
      

  4.   

    情况就是你说的这样,PHP要等到`$xtar_command`;结束的,怎么样才能让PHP立即跳转到别的内容呢?
    在后面加“exit”,好像效果不是很明显,还是要等到`$xtar_command`;结束!还有什么方法吗?
      

  5.   

    我不是说了么?
    用多进程~~~~
    pcntl_fork 开新进程~~~
      

  6.   

    pcntl_fork
    (PHP 4 >= 4.1.0)pcntl_fork -- Forks the currently running process
    Description
    int pcntl_fork ( void)
    The pcntl_fork() function creates a child process that differs from the parent process only in it's PID and PPID. Please see your system's fork(2) man page for specific details as to how fork works on your system. On success, the PID of the child process is returned in the parent's thread of execution, and a 0 is returned in the child's thread of execution. On failure, a -1 will be returned in the parent's context, no child process will be created, and a PHP error is raised. 例子 1. pcntl_fork() Example<?php$pid = pcntl_fork();
    if ($pid == -1) {
         die("could not fork");
    } else if ($pid) {
         // we are the parent
    } else {
         // we are the child
    }?>
     
     
    从手册上抄来的~~~~用法和系统函数 fork() 一样~~