inotifywait 目录或文件的监控

当目录或者文件有变化的时候执行 相应操作

src=/home/wwwroot/sssm/Api/upload

inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f' -e close_write,delete,create,attrib $src | while read file
do
     cd $src
     svn add *
     svn commit -m "add img" > /dev/null
     echo commit imgage to svn $(date) >> /home/wwwlogs/sssm/svnimg.log
done


#监控文件
inotifywait -mrq --timefmt '%d/%m/%y/%H:%M' --format '%T %w %f' -e modify,delete,create,attrib /root/test/1.txt | while read file
do
  echo xiugai $(date) >> /root/test/2.txt
done

  

posted on 2017-08-07 10:16  思此狂  阅读(224)  评论(0编辑  收藏  举报

导航