php - Notify of new files with inotify -
i need make script notifies log file when new file enters directory. use inotify shell script or php, examples have found in c. can give me example of this?
in addition, can inotify know when file done being copied?
this shell command write logfile whenever file created in /path/to/dir:
inotifywait -m -e create /path/to/dir >>logfile explanation:
-mtells inotifywait keep running. default exit after first event-e createtells inotifywait report on file create events./path/to/dirtarget directory watch. subdirectories not monitored unless recursive option,-rspecified.>>logfiletells shell redirect output filelogfile. if leave part off, output directed stdout , can watch in real time files created.
monitoring more events
inotifywait report on several different events. example, ran inotifywait in 1 window while writing file window:
$ inotifywait -m . setting watches. watches established. ./ open myfile ./ modify myfile ./ modify myfile ./ modify myfile ./ close_write,close myfile because above has no redirection, output appears on terminal.
the open event signifies files initial creation. close events indicates process done.
the exact set of events inotifywait show depends on system calls program monitoring uses. test above find out.
Comments
Post a Comment