Created
July 30, 2017 17:22
-
-
Save stigok/3af2ecfba3a6d419646ac212d4871234 to your computer and use it in GitHub Desktop.
File system watcher that executes a command when MOVED_TO event occurs, i.e. when rsync file transfer is complete
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Do something after rsync completes | |
# | |
# Usage: after-rsync <srcdir> <command> [...args] | |
set -x | |
srcdir=$1 | |
shift | |
inotifywait -m -r -e MOVED_TO --format='%f %w' "$srcdir" | | |
grep -ve '^\.' --line-buffered | # ignore temporary rsync files | |
while read filename directory | |
do | |
${@} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment