![]() Topic awaiting preservation: need help monitoring folder (Page 1 of 1) |
|
---|---|
Maniac (V) Inmate From: there...no..there..... |
![]() I need to be able to monitor a folder which clients are going to be uploading files. I have it that they can't delete files once uploaded but I need to have the folders monitored to shoot an email when something is uploaded. Such as username and file name and date of upload. |
Maniac (V) Inmate From: raht cheah |
![]() I assume you're using straight FTP instead of an uploading script? I assume this because the uploading could be made to report after upload. |
Maniac (V) Inmate From: there...no..there..... |
![]() yeah just straight FTP and I don't think LAMP is installed either. quote:
|
Maniac (V) Inmate From: raht cheah |
![]() |
Maniac (V) Mad Scientist From: :morF |
![]() Actually all you'd need it to do is, perhaps, store one value: the date and time of when it last executed. From that it can check the date and time the file was put onto the server, and determine which files are 'new' from that. It will save a lot of time in the long-run if the contents of the directory start to encompass a lot of file. |
Maniac (V) Inmate From: raht cheah |
![]() |
Maniac (V) Inmate From: there...no..there..... |
![]() quote:
|
Maniac (V) Inmate From: raht cheah |
![]() quote:
quote:
|
Maniac (V) Inmate From: there...no..there..... |
![]() ah...ok I gotcha. quote:
|
Paranoid (IV) Inmate From: Madison, Indiana, USA |
![]() CPrompt: What Operating System is this running on? code: find directory -newer time-stamp-file -print >> list-of-new-files touch time-stamp-file
|
Maniac (V) Inmate From: there...no..there..... |
![]() yeah, it's RedHat. I take it that is a bash script? Not real familiar with it code: $directory = 'files'; //directory se are working with $resc = opendir($directory); //open the directory if (!$resc) { //error handling echo "Problem opening directory $directory. Error: $php_errormsg"; exit; } $files = array(); //put the files in an array while ($filename = readdir($resc)) { //loop through directory and grab all file names if (is_file($directory . '/' . $filename)) { $files[] = $filename; // Add to the array } } $cnt = count($files); //see how many files are in the directory for ($i = 0; $i < $cnt; $i++) { echo "<b>" . $files[$i] . "</b> <br />"; // Display filename or do whatever }
code: echo date("F d Y h:i:s.", filectime($filename));
|
Maniac (V) Inmate From: there...no..there..... |
![]() OK, I actually got the PHP script to work as far as displaying the file name and the "filectime". |
Paranoid (IV) Inmate From: Madison, Indiana, USA |
![]() If you want to get a list of new files every time the cron runs change the >> to >. That will cause the command to truncate the file before it writes the new list. code: #! /bin/bash /usr/bin/find .... /bin/touch ...
code: #! /bin/bash time=`/bin/date "+%y%m%d%H%M%S"` filename="$time-file.lst" /usr/bin/find directory -newer time-stamp-file -print > $filename /bin/touch time-stamp-file |