Skip to content

Instantly share code, notes, and snippets.

@rankun203
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rankun203/03e3bbc1db9aa9489236 to your computer and use it in GitHub Desktop.
Save rankun203/03e3bbc1db9aa9489236 to your computer and use it in GitHub Desktop.
监视文件夹并执行操作
#!/bin/bash
#author rankun203@gmail.com
#ref http://unix.stackexchange.com/a/24955
cd /home/rankun203
inotifywait -r -m ./www -e create -e moved_to |
while read path action file; do
echo "The file '$file' appeared in directory '$path' via '$action'"
rsync -avzrhu --update --progress --chmod=u+rwx,g+rwx,o+rwx "$path$file" rankun203@s.rankun.org:/home/rankun203/html/files
done
@rankun203
Copy link
Author

Update, use rsync, grant permissions to file directly.

@rankun203
Copy link
Author

Update, -h: human readable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment