centos7 启动python后端服务与停止服务的sh脚本


centos7 启动python后端服务与停止服务

分别在工程目录下新建启动脚本和停止脚本。

1、启动服务脚本

start_srv.sh:

python3 start_srv.py

运行 nohup ./start_srv.sh & 以守护进程的方式启动这个服务。

2、停止服务脚本

stop_srv.sh:

sp_pid=`ps -ef | grep start_srv | grep -v grep | awk '{print $2}'`

if [ -z "$sp_pid" ];

then

 echo "[ not find start_srv pid ]"

else

 echo "find result: $sp_pid "

 kill -9 $sp_pid

fi

运行 ./stop_srv.sh 停止这个服务。

参考:https://www.cnblogs.com/zeng1994/p/13a2c5a28e55dd3abc2c75a4fb80371a.html

以上。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM