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

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

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

1、启动服务脚本

start_srv.sh:

python3 start_srv.py

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

2、停止服务脚本

stop_srv.sh:

sp_p 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

以上。