環境 Debian 8
使用工具 : inotify-tools
# apt-get install inotify-tools
使用 inotifywait 撰寫 shell
# vim watch.sh
#!/bin/sh
inotifywait -m 預監控的目錄 -e create -e moved_to |
while read path action file; do
echo "The file '$file' appeared in directory '$path' via '$action'"
cat content.txt | mail -s "[xxx] xx 通知 - $file" fifi@xxxx -- -f fifi@xxx
# do something with the file
done
# chmod + x watch.sh
# runlevel
沒有留言:
張貼留言