0

I need to use inotifywait to watch for a folder. Files come into that folder can be very large, that's why I use close_write and wait for the file to complete writing. However, I also want an event to be triggered when a file is renamed under the same folder. So what event should I watch for file rename? I looked at the inotifywait manual page and I didn't find what I am looking for. The inotify IN_MOVED_TO event seems the one I need but that's not inotifywait.

I also tried the moved_to, but first, it didn't trigger the event when file is renamed; second, if I have both close_write and moved_to, the moved_to might be triggered before close_write is triggered in case the file is very large. Thanks.

 inotifywait --monitor --event close_write --format '%w%f %e %T' --timefmt '%F %T' $watchFolder 
   |  while read eventOutput
 do
    echo "eventOutput is:" $eventOutput
 done
jlp
  • 1,656
  • 6
  • 33
  • 48
  • Have you tried `MOVED_TO`? – John1024 May 16 '16 at 22:46
  • I did. But it didn't trigger the event. Also, when there is no file rename, if the file is very large, the move_to might be triggered before the file completes writting. – jlp May 16 '16 at 22:49
  • _"I also tried the moved_to, but first, it didn't trigger the event when file is renamed;"_ I have never seen that happen. – John1024 May 17 '16 at 05:58

0 Answers0