首页 > 代码库 > inotify监控目录变化重启服务器tornado项目

inotify监控目录变化重启服务器tornado项目

 

pycharm 配置了提交服务器项目每次pycharm修改后,虽然保存到服务器但是项目还得自己去服务器kill再启动。就花几分钟写了shell脚本用于监控项目目录变化并重启tornado项目的脚本

 如果技术不懂需要请联系我

[liujianzuo@zl scripts]$ cat realtime_rsync.sh#!/bin/bash#parahost01=10.0.0.253#src=http://www.mamicode.com/backup"/home/liujianzuo/htdocs/tornado/my_tornado_blog/my_tornado_blog"dst=backupuser=rsync_backuprsync_passfile=/etc/rsync.passwordinotify_home=/usr/local/inotify/${inotify_home}/bin/inotifywait -mrq --timefmt ‘%d/%m/%y %H:%M‘ --format ‘%T %w%f‘ -e close_write,delete,create,attrib $src         | while read file                do                /bin/sh /server/scripts/manage.sh               done[liujianzuo@zl scripts]$ cat manage.sh #!/bin/bash#by liujianzuo# date:20160801pid=`ps -ef |grep App.py|grep -v grep|awk ‘{print $2}‘`n=`echo $pid|wc -m`echo $pidecho $nif [ $n -lt 2 ];then        cd /home/liujianzuo/htdocs/tornado/my_tornado_blog/my_tornado_blog        nohup python3 App.py &else        ps -ef |grep App.py|grep -v grep|awk ‘{print $2}‘|xargs kill        ps -ef |grep App.py|grep -v grep|awk ‘{print $2}‘|xargs killfi  

  

 

inotify监控目录变化重启服务器tornado项目