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 に答える