0

我正在尝试在我的基于 linux 的服务器中运行这个 php 脚本。

$today      = strtotime("today");
$tommorow   = date("Y-m-d", strtotime("+1day",$today));
$today      = date("Y-m-d");

//Endless loop because the data here updates around the clock 
while(1){

    while (time() <= strtotime("$tommorw 8:00PM")){

            sleep(30);
            flush();
        }

    }//end 24 h loop
    //save the file as a date file and delete it's content


    //move on to the next day   
    $today      = strtotime("today");
    $tommorow   = date("Y-m-d", strtotime("+1day",$today)); 

}//end of endless loop 

如果我从一个简单的浏览器运行它,它就可以正常工作(当然,当我关闭它时它会停止工作)。

我正在尝试通过 perl 脚本运行它

chdir("mydir");
exec('indices.php');  #tryed also system("php indices.php");

并像这样运行 perl 脚本

./PROMadadim.pl >> ./PROMadadim.log &

但是当我尝试从服务器运行它时它不起作用。

4

1 回答 1

2

通过查看代码,您可能会更好地设置 CRON 作业。如果您的服务器不支持 CRON,那么您可以尝试添加...

set_time_limit(0);

或尝试将 -q 添加到 php 命令中,如下所示:

php -q /home/user/example.php
于 2012-06-21T22:10:19.963 回答