2017-12-16 8 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. 
関連する問題