pycharm 配置了提交服务器项目每次pycharm修改后,虽然保存到服务器但是项目还得自己去服务器kill再启动。就花几分钟写了shell脚本用于监控项目目录变化并重启tornado项目的脚本
如果技术不懂需要请联系我
[[email protected] scripts]$ cat realtime_rsync.sh #!/bin/bash #para host01=10.0.0.253 #src=/backup src="/home/liujianzuo/htdocs/tornado/my_tornado_blog/my_tornado_blog" dst=backup user=rsync_backup rsync_passfile=/etc/rsync.password inotify_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 [[email protected] scripts]$ cat manage.sh #!/bin/bash #by liujianzuo # date:20160801 pid=`ps -ef |grep App.py|grep -v grep|awk ‘{print $2}‘` n=`echo $pid|wc -m` echo $pid echo $n if [ $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 kill fi
时间: 2024-10-10 17:55:39