I have a shell script and within which i am using 'inotifywait' to monitor three directories. As soon as file comes within directory 'dirToProcess' some processing is done and then files get moved to either 'successDir' or 'failedDir' directory.
Now as soon as any files gets moved or copied in any of the directory I want inotifywait to get executed.
Here is the code i am executing:
inotifywait $dirToProcess $successDir $failedDir -e create -e moved_to --
exclude "\.(swx|swp|end|en1)" |
while read path action file; do
if [ -f $dirToProcess/$file ]; then
doSomething;
elif [ -f $successDir/$file ]; then
cleanDir $successDir # function which has some specific logic
exit 0;
elif [ -f $failedDir/$file ]; then
cleanDir $failedDir # function which has some specific logic
exit 0;
else
c4lx_log "File $file not in poll, archive or failed, then why did we get notified?"
exit 0;
fi
Here is the problem: As soon as files comes in 'dirToProcess' inotifywait notice it and gets called. But after processing when files are getting moved to '$successDir' or '$failedDir' ( by same code which processed files within 'dirToProcess' inotifywait does not get executed. But if i am moving files manually in either of those two dir everything seems to be working fine.
Can someone give me some pointer here or explain if i am missing any details here.
( i tried using -m or -r option with inotifywait but does not seems to be working )
Thanks