I'm scripting a special program to my company.
By using Inotifywait from inotify-tools, I'm watching a specific folder for new items, and as soon a new file appears, it will be encrypted with gpg and moved to another folder for further treatment.
For a single file, it works fine, but I noticed a problem: When a new file enters while another one is being processed, he is ignored and intotifywait don't treat it, so he stays stucked in the folder. Is there any way to handle multiple files at the same time?
Here is the code I have so far:
origin=/BRIO/QPC/conclu01/Criptografar output=/BRIO/QPC/conclu01/GPG finished=/BRIO/QPC/conclu01/Concluido while true; do inotifywait -e create -e moved_to -e close_write -e moved_from $origin --exclude ".*(\.filepart|gpg|sh)" | while read dir event file do echo $event if [ "$event" == 'CLOSE_WRITE,CLOSE' ] || [ "$event" == 'MOVED_TO' ] || [ "$event" == 'CREATE' ] then echo "Found the file $origin/$file, starting GPG" sleep 5 gpg --encrypt --recipient Lucas --output "$output/$file.gpg" "$origin/$file" echo "The file $file was succesfully encrypted to $output/$file.gpg" mv -f "$origin/$file" $finished echo "The file $origin/$file was moved" fi done done