Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # monitor file changes in a target directory
- if [ "$*" = "" ]; then
- echo "File Monitoring"
- echo "USAGE: $0 <target directory>" | sed "s/.\///g"
- echo ""
- exit 0
- fi
- LOGDIR="$HOME/.log"
- if [ ! -d $LOGDIR ]; then
- mkdir -p $LOGDIR
- fi
- TARGET_DIR="$*"
- LOGNAME="$LOGDIR/`date -I`.log"
- inotifywait -m -r --format '%T %e %w%f' --timefmt '%F %T' -e modify -e move -e create -e delete $TARGET_DIR | while read line
- do
- unison -batch /dir/on/local/machine ssh://root@ip//dir/on/remote/machine
- # add more unison commands here if you want for multiple servers.
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement