1

I have a problem when executing the PHP files as background process. I have two PHP file as follow :

index.php

<?php   
    $cmd = "php cmdReadReport.php";
    if (substr(php_uname(), 0, 7) == "Windows"){ 
        pclose(popen("start /B ". $cmd, "r"));  
    } 
    else { 
        exec($cmd . " > /dev/null &");   
    } 
?>

cmdReadExcel.php

<?php
    $reportname = "./report/lw321.xls";
    $thereport = new Report();
    $thereport->readReport($reportname)
?>

My goal is to run Report.readReport as background process. readReport function is function which reads Excel file and saves its rows to database.

I have followed the tutorial but there is no result/no rows inserted. Is there anything wrong in the code?

Regards,

4

1 回答 1

0

您可以从客户端而不是服务器启动脚本执行。像这样:

www.example.com/scripts/cmdReadReport.php?keypass=Giw3m4d9BaJO0ua0WFtG

然后只需使用 CURL 或其他东西请求此页面。这种方法更便携。

于 2013-05-14T03:52:48.357 回答