Why does inotitywait with "echo '---' >> file" only emit an "OPEN" event?

StackOverflow https://stackoverflow.com/questions/18295545

  •  24-06-2022
  •  | 
  •  

سؤال

Why does echo "---" >> file only generate a ./ OPEN file event? Shouldn't it generate other events too?

For example:

# In a script:
while true; do
  change=$(inotifywait -q -r . )
  echo $change
done

# Somewhere else:
echo "--" >> file
echo "--" >> file
echo "--" >> file
هل كانت مفيدة؟

المحلول

it is exiting after the first event and starting the loop over, by the time the first watch is removed and the second added, the events have already transpired. You can try:

inotifywait -q -m -r . | while read CHANGE; do
    case "$CHANGE" in
        *)echo $CHANGE;;
    esac
done

the -m will continue monitoring after the first event

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top