后台运行python服务 起停脚本

启动脚本

start.sh

#!/bin/bash

nohup <command> > /dev/null 2>&1 & echo $! > command.ppid

停止脚本

#!/bin/bash

ppid=`cat command.ppid`

ps -o pid --ppid $ppid --no-heading | awk '{print$1}' | xargs -I {} kill {}

 

posted @ 2022-08-29 10:56  WenderWang  阅读(63)  评论(0)    收藏  举报