0

I was wondering if there is any possible way to check to see if my files have been modified in anyway. Is there any way to check the logs to see if anything has changed. These files are located on a folder within a Mac Pro server.

  • do you have to do this with php? –  May 01 '17 at 03:41
  • PHP suggestions include testing filesize() against a previously stored filesize. another is counting lines in the file. http://stackoverflow.com/questions/2162497/efficiently-counting-the-number-of-lines-of-a-text-file-200mb – Jason Joslin May 01 '17 at 03:45
  • If your code is the app editing the file you could log that a change has been made in the file with a timestamp in another file or db – Jason Joslin May 01 '17 at 03:46

1 Answers1

0

I guess you can use glob() and filemtime(), i.e.:

$files = glob("/some/dir/*");
foreach ($files as $file) {
    if (file_exists($file)) {
        echo "$file was last modified: " . date("F d Y H:i:s.", filemtime($file)) . "\n";
    }
}

In my case, it outputs:

/test_dir/s.html was last modified: April 24 2017 05:38:04.
/test_dir/sads.html was last modified: May 01 2017 04:43:02.
Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268