2012-06-21 5 views
0

리눅스 기반 서버에서이 PHP 스크립트를 실행하려고합니다.무한 루프로 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 

간단한 브라우저에서 실행하면 정상적으로 작동합니다

그래서

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

같은 펄 스크립트를 펄 스크립트

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

을 통해 그것을 실행하고 실행하려고하지만 난에서 실행하려고 할 때 작동하지 않습니다 섬기는 사람.

+0

의라는 데몬, 구글 "PHP 데몬 " –

+3

"왜 작동하지 않습니까? " 구체적으로 무엇이 발생합니까? 실행 중이지만 기능이 잘못 되었습니까? 전혀 실행되지 않는가? (ps -A는 아무것도 표시하지 않는다)? – webbiedave

+0

cron 작업을 설정하십시오. 무한 루프가 거의 원격으로 권고되지 않습니다. – Ciro

답변

2

코드를 보면 CRON 작업을 설정하는 것이 좋습니다. 서버가 CRON을 지원하지 않는 경우에 당신은 ... 추가

set_time_limit(0); 

을 시도하거나 지금처럼 PHP는 명령에 -q를 추가하는 시도 할 수 :

php -q /home/user/example.php 
관련 문제