Advertisement
Guest User

Untitled

a guest
Jul 6th, 2014
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.58 KB | None | 0 0
  1. #!/bin/bash
  2. # monitor file changes in a target directory
  3.  
  4. if [ "$*" = "" ]; then
  5.  echo "File Monitoring"
  6.  echo "USAGE: $0 <target directory>" | sed "s/.\///g"
  7.  echo ""
  8.  exit 0
  9. fi
  10.  
  11. LOGDIR="$HOME/.log"
  12.  
  13. if [ ! -d $LOGDIR ]; then
  14.  mkdir -p $LOGDIR
  15. fi
  16.  
  17. TARGET_DIR="$*"
  18. LOGNAME="$LOGDIR/`date -I`.log"
  19.  
  20. inotifywait -m -r --format '%T %e %w%f' --timefmt '%F %T' -e modify -e move -e create -e delete $TARGET_DIR | while read line
  21. do
  22. unison -batch /dir/on/local/machine ssh://root@ip//dir/on/remote/machine
  23. # add more unison commands here if you want for multiple servers.
  24. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement