0

I'm using the following bash script to test inotifywait.

while true; do
  inotifywait -r -e modify,create,delete "$DIRECTORY_TO_WATCH"
done

inotifywait is listening to created files:

/directory_to-watch/ CREATE test (copy).sh

Also modified files:

/directory_to-watch/ MODIFY test.sh

But say, I copy a file and then delete it, inotifywait doesn't log anything. What's happening?

4
  • 5
    You are restarting inotifywait after every event, and with recursion it may have a fairly slow start-up procedure (and be a considerable resource issue). That means there is a race condition against the rm command. Try removing the while true loop, and using the --monitor option in inotifywait. Commented Feb 13 at 12:30
  • 1
    Does this work fatrace -t -f 'WD<>+'? Commented Feb 13 at 13:14
  • @Paul_Pedant that's definitely due an answer Commented Feb 13 at 14:23
  • @Paul_Pedant I removed the while loop and tried this: inotifywait -r -m -e modify,create,delete "$DIRECTORY_TO_WATCH" (and without the -r). Still, nothing is logged when I delete a file.
    – wyc
    Commented Feb 13 at 15:42

1 Answer 1

0

I found out why. Pressing Delete was moving the file to the trash (I had to listen to this with moved_from).

To actually delete the file, I had to press Shift + Delete.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .