2013-06-27 4 views

답변

0

cron으로 시작한 스크립트를 1 분마다 시작하고 날짜가 아니라 이전과 현재의 디렉토리 목록의 차이점을 확인해 볼 수 있습니다. 완벽한 솔루션은 아니지만 작동 할 것입니다. 와

확인 디렉토리 arays :

$dirs = array_filter(glob('*'), 'is_dir'); 

array_diff

+0

Bingo 정확히 어떻게 할 것인가? – user2473178

+0

여기에서 디렉토리를 찾는 방법을 확인하십시오 : http://stackoverflow.com/questions/2524151/php-get-all-subdirectories-of-a-given-directory?answertab=active#tab-top 그리고 디렉토리 배열 비교 with : [array_diff] (http://php.net/manual/en/function.array-diff.php) –

1

Quote from @Alin Purcaru으로 나중에 비교 :

사용 filectime을. Windows의 경우 생성 시간을 반환하고 Unix의 경우 변경 시간은 Unix에서 (대부분의 파일 시스템에서) 생성 시간이 없으므로 얻을 수있는 최상의 시간입니다.

참조 파일을 사용하여 파일 보존 기간을 비교하면 데이터베이스를 사용하여 새 파일을 찾을 수 있습니다.

// Path to the reference file. 
// All files newer than this will be treated as new 
$referenceFile="c:\Data\ref"; 
// Location to search for new folders 
$dirsLocation="c:\Data\*"; 

// Get modification date of reference file 
if (file_exists($referenceFile)) 
    $referenceTime = fileatime($referenceFile); 
else 
    $referenceTime = 0; 

// Compare each directory with the reference file 
foreach(glob($dirsLocation, GLOB_ONLYDIR) as $dir) { 
    if (filectime($dir) > $referenceTime) 
    echo $dir . " is new!"; 
} 

// Update modification date of the reference file 
touch($referenceFile); 

또 다른 해결책은 데이터베이스를 사용할 수 있습니다. 데이터베이스에없는 폴더는 모두 새 폴더입니다. 이렇게하면 수정 된 폴더를 포착하지 않습니다.

+0

fileatime은 마지막 액세스 시간 (즉, 수정 된 시간)을 반환합니다. $ referenceFile과 $ dirsLocation을 비교하면 condirion이 true가되고 항상이 파일이 새로운 것입니다. – user2473178

관련 문제