2017-12-16 17 views
-1

FTP 서버가 있고 운영자가 FTP 페이지를 통해 수동으로 업데이트합니다. 정확하게 수행 할 때이를 알지 못합니다.PHP에서 마지막으로 수정 된 파일 및 폴더 찾기 재귀 적으로

수정 된 폴더를 확인하고 생성되거나 수정 된 새 폴더의 경로를 반환하는 스크립트를 작성하고 싶습니다.

나는 그가 보통 어떤 경로에 새 폴더를 만들거나 삭제한다고 말해야합니다.

ftp_nlist 통해 모든 파일과 폴더를 반복적으로 읽은 다음 새 파일 인 경우 데이터베이스의 경로를 확인하거나 저장하거나 데이터베이스에서이 행을 삭제하십시오.

최상의 최적화를 위해 아이디어와 코드를 공유하십시오.

+1

올바른 경로에있는 것 같습니다. 프로세스의 마지막 수정 날짜 사용을 고려하십시오. –

+1

안녕하세요. 우리에게 보여줄 코드가 있습니까? [최소한의 완전하고 검증 가능한 예제를 만드는 방법] (https://stackoverflow.com/help/mcve)을 읽어보십시오. – Michel

답변

0

bash 스크립트 find으로 폴더와 파일의 최종 수정 시간을 확인할 수 있습니다. 다음은 몇 가지 PHP의 예는 다음과 같습니다

exec('find . -mtime -1 -type d', $output); 
// $output: list of folders modified within 24 hours 
unset($output); 

exec('find . -mtime -1 -type f', $output); 
// $output: list of files modified within 24 hours 
unset($output); 

exec('find . -mtime +0 -type f', $output); 
// $output: list of files modified greater than 24 hours 
unset($output); 

당신은 -amin, -atime, -cmin, -ctime, -mmin-mtime도 이러한 옵션을 확인해야합니다.

-amin n 
      File was last accessed n minutes ago. 

    -atime n 
      File was last accessed n*24 hours ago. When find figures out 
      how many 24-hour periods ago the file was last accessed, any 
      fractional part is ignored, so to match -atime +1, a file has 
      to have been accessed at least two days ago. 

    -cmin n 
      File's status was last changed n minutes ago. 

    -ctime n 
      File's status was last changed n*24 hours ago. See the 
      comments for -atime to understand how rounding affects the 
      interpretation of file status change times. 

    -mmin n 
      File's data was last modified n minutes ago. 

    -mtime n 
      File's data was last modified n*24 hours ago. See the 
      comments for -atime to understand how rounding affects the 
      interpretation of file modification times.